XML parsing containing XML in elements, can this be done

I have a "complex element" that is in XML. Then a "workitem" (in xml) that contains a lot of other information, and I would like it to contain a string containing a complex element in xml.

eg:

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

However, trying SAX and other java parsers, I can not get it to process this line, it doesn’t like <or "in line, I tried to escape and convert" to ".

Anyway around this at all? Or will I have to come up with a different solution?

thanks

+3
source share
5 answers

, , XML, , , . XML, , :

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

, , , XML.

( CDATA) XML.

XML, TagSoup library, , , . ( : TagSoup HTML, , -HTML-)

(- , doco maven)

+5

, CDATA. :

<inouts name="ClaimType" type="complex">
  <![CDATA[
    <xml string here>
  ]]>
</inouts>

, :

<inouts name="ClaimType" type="complex">
  <value1>
    <![CDATA[
      <xml string here>
    ]]>
  </value1>
  <value2>
    <![CDATA[
      <xml string here>
    ]]>
  </value2>
</inouts>

:

<inouts name="ClaimType" type="complex">
  <value id="complexString1">
    <![CDATA[
      <xml string here>
    ]]>
  </value>
  <value id="complexString2">
    <![CDATA[
      <xml string here>
    ]]>
  </value>
</inouts>
+5

CDATA

NB , . , .

+2

, , escaping (< as <and> as > ) , .

: Xml Any ( ) CDATA.

0
source

you http://www.doingitwrong.com/

If it inouts/@valuereally is a tree structure (i.e. XML), then it should not be an attribute, it should be a child of:

<inout name="ClaimType" type="complex">
    <value>
        <some-arbitrary>
            <xml-stuff/>
        </some-arbitrary>
    </value>
</inout>

If this is not the case, the correct XML is actually guaranteed, but it just looks like this because you put several pointed brackets in it, then you should ask yourself if there is a better way to solve this problem. This does not work, use <![CDATA[as some of them have already suggested.

0
source

Source: https://habr.com/ru/post/1702806/


All Articles