Using A String That Contains The - ">" Char Inside A XML Document

  • Thread starter Thread starter Jerry Pisk
  • Start date Start date
J

Jerry Pisk

Why don't you just encode those characters? > and <, just like in
HTML. Or you can use CDATA sections to include pretty much anything. Neither
is .Net specific, they're just basic XML concepts (you're blaming the wrong
guy for your problems).

Jerry
 
Hey,
I'v created a define typed DataSet using an XSD Schema, and I tried to read
an XML file into the dataset and update my table with the new data.
The problem is, that I have a feild in the table/XSD Schema, that is of type
string (varchar2 to be exact),
And when I try to put a string containing - ">" or - "<" in the XML that
will be read into the define typed DataSet, I get an error saying that my
XML is not well formed...
Is there a way to tell .NET not to parse a certain part of a XML Document?
Thanks ahead

--Ram
 
Ram said:
Hey,
I'v created a define typed DataSet using an XSD Schema, and I tried to read
an XML file into the dataset and update my table with the new data.
The problem is, that I have a feild in the table/XSD Schema, that is of type
string (varchar2 to be exact),
And when I try to put a string containing - ">" or - "<" in the XML that
will be read into the define typed DataSet, I get an error saying that my
XML is not well formed...
Is there a way to tell .NET not to parse a certain part of a XML Document?
Thanks ahead

In any XML document, the <, >, and & characters must be written using
character entities when they are part of the 'data' of the document
(unless they are in a CDATA section):

&lt;
&gt;
&amp;
 
Hey guys,
First, thanks for the reply!
Second, I might be blaming the wrong guy (Bill Gates ;) ),
But the 2 questions are:
1 - If I do use this CDATA thing, will it still be ok with my XSD Schema?
2 - If I do change it from - ">" to it's code, when will this change
happen - when I parse the XML into the XMLDocument,
BEFORE I load it into the DataSet, - OR - when I load the XMLDocument into
the DataSet?
Thanks again,

--Ram
 
1 - Depends on your schema.
2 - You're thinking about it the wrong way. &gt; is a representation of the
character, when an XML parser reads &gt; it will treat it as the literal >
character. Entities are just an encoding scheme representing special
characters.

Jerry
 
Ram said:
First, thanks for the reply!
Second, I might be blaming the wrong guy (Bill Gates ;) ),
But the 2 questions are:
1 - If I do use this CDATA thing, will it still be ok with my XSD Schema?

It should be, yes.
2 - If I do change it from - ">" to it's code, when will this change
happen - when I parse the XML into the XMLDocument,
BEFORE I load it into the DataSet, - OR - when I load the XMLDocument into
the DataSet?

It would be parsed so that the contents of the text node would include
the ">" in the XmlDocument. Conceputally, the XmlDocument itself has a
text node which contains ">", but it's represented in an XML file as
&gt;

(If you're familiar with C#, C or Java, it's the equivalent of a string
like "hello\tthere" - the string actually contains a tab, but the tab
is just represented in the source code as \t.)
 
Back
Top