CDATA - XML - SCHEMA

P

pshymon123

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.
 
D

David Carlisle

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top