Michal Jurník
Michal Jurník

Reputation: 830

How to make string from xml structure?

is there any way how to make from:

  <content>
    <headline>Big headline</headline>
    <headline>Small headline</headline>
  </content>

string in XML structure? Something like:

<xml>
<root>
  <pageContent>
    "<content><headline>Big headline</headline><headline>Small headline</headline</content>"
  </pageContent>
</root>

where all in "" is something like string. I mean string for parsers. Thx for reply.

Upvotes: 0

Views: 227

Answers (1)

Gertjan Assies
Gertjan Assies

Reputation: 1900

I assume you want the first xml to be treated as text in the second xml, it that case you have to escape the special characters

<xml>
  <root>
    <pageContent>
      $lt;content$gt;$lt;headline$gt;Big headline$lt;/headline$gt;$lt;headline$gt;Small headline$lt;/headline$lt;/content$gt;
    </pageContent>
  </root>
</xml>

another way is to use CDATA which will ignore any xml markup in between

<xml>
<root>
  <pageContent>
    <![CDATA[
    <content><headline>Big headline</headline><headline>Small headline</headline</content>
    ]]>
  </pageContent>
</root>

Upvotes: 1

Related Questions