简体   繁体   中英

How to parse newlines in XML Tags?

I am parsing a RSS feed, in that <description> tag contains some \\n line characters like this

    <?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<item>
      <guid>http://www.horseandhound.co.uk/blogs/7619/314307.html</guid>
      <title>Chloe Chubb&#039;s s<title>Chloe Chubb&#039;s showing blog: Horse of the Year Show (HOYS) preparations</title>
      <description>So it is a week before HOYS and I have somehow managed to stay a bit oblivious to it all. It is only when I log onto Facebook and see the many, many statuses talking about it that I realise it’s only just around the corner! Then the butterflies begin.
&lt;br /&gt;
 /&gt;
My pre-HOYS diet was going well until last weekend when me and my best mates headed for a weekend away by the beach. Cue huge amounts of cheese, wine and cake and with the 5 pounds I’d lost, 2 went straight back on.&amp;#8230;</description>
      <url>http://www.horseandhound.co.uk/blogs/7619/314307.html</url>
</item>
</channel>
</rss>

Here I am able to parse the text up to first line "some text in line1.." but from the next line, the remaining text is not parsed. I am using Dom parser .Please suggest how to resolve this.

You can use the entity &#10; to represent a newline in an XML attribute.
&#13; can be used to represent a carriage return.
A windows style CRLF could be represented as &#13;&#10; .

See XML spec for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM