Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Schema "What replaced PCDATA?"

Status
Not open for further replies.

tcrosswell

IS-IT--Management
Oct 14, 2001
26
GB
Is anyone able to help me?

Here is my XML file:

<product>
<notes>FREE £2 of digital printing FREE minitripod worth £8 FREE Qbeo PhotoGenetics 2.0 worth £24.99 Supplied accessories 2MB SmartMedia&#153; card Case and strap USB cable & video cable Two AA alkaline batteries...</notes>
</product>

With a DTD I would have expressed that this element contained PCDATA so that it is not interpreted as markup. Then this file would be Well-formed. I am trying to learn how to use Schema's and at present I have:

<xs:complexType name=&quot;camera&quot;>
<xs:sequence>
<xs:element name=&quot;notes&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/>
</xs:sequence>
</xs:complexType>

but when I check to see if the XML file is Well-formed I get an error and says that the &quot;&&quot; in the <notes/> element is the problem.

How do I get round this? I am using type=&quot;xs:string&quot; do I need to use anything else?


Thanks very much and I hope this makes sense I am new to XML and Schema's

Tom
 
You should always use the escape sequence '&amp;' for ampersands in XML. Other characters that are usually escaped are:
< &lt;
> &gt;
' &apos;
&quot; &quot;

Alternatively, you can use CDATA. For example:
<root>
<![CDATA[
&><'&quot;
]]>
</root>
 
I'll repost the previous answer - I didn't preview my post before submitting it and the escape sequence examples were printed incorrectly.

You should always use the escape sequence '&amp;' for ampersands in XML. Other characters that are usually escaped are:
< &lt;
> &gt;
' &apos;
&quot; &quot;

Alternatively, you can use CDATA. For example:
<root>
<![CDATA[
&><'&quot;
]]>
</root>

When parsed, the <![CDATA[ and ]]> declarations are ignored but the characters between these declarations are not escaped.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top