-2

I'm getting an xml document from a PHP script.

The XML schema looks something like this:

<Items>
  <Item>
    <ID> 
       123g8fdg
    </ID>
    <Name>
       Michael
    </Name>
    <Note>
       Some notes, for example a small xml snippet: <randomxml><...
    </Note>
  </Item>    
</Items>

The Note node could have any value (even an XML snippet) While trying on getting the following XML data back from the server, I noticed, that the C# LoadXML function fails if the Note is the following:

"Finish date <= Start date + 1 year"

The "<" character breaks it up (I can see that even in the C# XML Visualizer while debugging)

Any ways to ignore any specific XML element in the notes section, so it doesn't interfere with the parser and basic structure?

Laureant
  • 979
  • 3
  • 18
  • 47
  • 4
    Given XML is not valid, you should use CDATA here instead plain text, http://stackoverflow.com/questions/2784183/what-does-cdata-in-xml-mean – tym32167 Nov 28 '16 at 11:36
  • Go fix your PHP script. If your XML contains that text inside an element, it's not valid XML. – Charles Mager Nov 28 '16 at 11:49

1 Answers1

0

You need to encode the value < as &lt;. You can't use < because it is mistaken for opening of tag.

Here is online encoding tool for xml

mybirthname
  • 17,949
  • 3
  • 31
  • 55
  • So you proposal is to read the XML in C#, then post that data to an online form, read it back in C# and then start processing it? – Thomas Weller Nov 28 '16 at 11:49
  • @ThomasWeller No I propose to check this online tool if he has some doubts if an element need encoding. – mybirthname Nov 28 '16 at 11:50