0

I have an XML defined something like this.

<object text="this is a <a>some text</a>" />

My SAXParser is unable to parse this XML as it contains <> tag in its attribute. Anyway to solves this?

I tried an online syntax checker and it failed. So does it mean that you cannot define <> tag in an XML attribute?

humansg
  • 735
  • 3
  • 12
  • 30
  • >I have an XML. Wrong. You don't have an XML. If you want to handle non-XML data, you will need to use non-XML tools to repair it. – Michael Kay Sep 27 '12 at 08:39

1 Answers1

1

Absolutely this is not valid XML. You will need to ensure you escape these characters as discussed in the W3C document http://www.w3.org/TR/xml/#dt-escape

For the sake of completeness here is your example and what it will look like if you escape it

<object text="this is a &lt;a&gt;some text&lt;/a&gt;" />

or;

<object text="this is a &#38;#60;a&#62;some text&#38;#60;/a&#62;" />
ramsinb
  • 1,985
  • 12
  • 17