CDATA - XML - SCHEMA

Discussion in 'XML' started by pshymon123@yahoo.co.uk, Apr 26, 2005.

  1. Guest

    I would like to add an element with a CDATA in it but I cannot seem to
    add it.
    Firstly I add this to my XML Schema:-

    <xsd:element name="test" type="xsd:string"/>

    then I add to my XML document:-

    <test>
    <[CDATA[hello]]>
    </test>

    and when I try to validate it, I get that is should be a comment.

    Help!

    Simon.
    , Apr 26, 2005
    #1
    1. Advertising

  2. "" <> writes:

    > I would like to add an element with a CDATA in it but I cannot seem to
    > add it.
    > Firstly I add this to my XML Schema:-
    >
    > <xsd:element name="test" type="xsd:string"/>
    >
    > then I add to my XML document:-
    >
    > <test>
    > <[CDATA[hello]]>
    > </test>
    >
    > and when I try to validate it, I get that is should be a comment.
    >
    > Help!
    >
    > Simon.


    The syntax for CDATA is <![ you are missing the ! But note that CDATA
    only affects the interpretation of the characters < and & so putting it
    around hello has no affect.

    <test>
    <![CDATA[hello]]>
    </test>

    Is the same to a schema validator (and most other XML applications) as

    <test>
    hello
    </test>

    in both cases the content of the element is
    newline h e l l o newline

    David
    David Carlisle, Apr 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page