Java – parses XML that contains XML in an element, which you can do

I have a "complex item" in XML, and then a "WorkItem" (in XML) containing a lot of other information. I want this to contain a string containing complex items in XML

For example:

<inouts name="ClaimType" type="complex" value="<xml string here>"/>

However, I can't let sax and other Java parsers handle this line. It doesn't like < or "s" in the string. I try to escape and convert "to" Do you have this anyway? Or do I have to propose another solution? thank you

Solution

I think you will find that the XML you are processing will not parse many parsers because it is invalid If you can control XML, you need at least escape attributes, so it is similar to:

<inouts name="ClaimType" type="complex" value="&lt;xml string here&gt;" />

Then, once the attribute is extracted, it can be re parsed to treat it as XML

Alternatively, you can use one of the above methods (using the CDATA section) to do some re - decomposition of XML

If you can't control XML, you can try parsing it using tagsoup library to understand how you work (Disclaimer: I only use tagsoup for HTML. I don't know how it works with non HTML content)

(the tag soup website actually appears on ATM, but you should be able to find enough docos on the Internet and download them through Maven repository)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>