I am trying to parse this XML:
<data>
<item field="abcdef '<>&" row="another text" />
</data>
I should get abcdef '<>& for getAttribute('field') and another text for getAttribute('row'). But if my data contains <>& etc XML is not parsed correctly. How can I parse it correctly?
It's malformed XML. You need to encode '<>&
as '<>&
. This is what well formed XML looks like:
<data>
<item field="abcdef '<>&" row="another text" />
</data>
You need to tidy the XML before you can parse it with an XML parser.