开发者

new line expression in XML

I create an XML in PHP Zend framework using DOM Class. To put a new line in XML element textnode an expression &lt;<BR>&gt; is passed. But when I pass a string with &lt;<BR>&gt; the generated XML will have &amp;lt;BR&amp;gt; instead actual expression &lt;<BR>&gt;. and so, the display of data from XML will print <BR> instead of new line.

How to prevent modification of t开发者_运维问答he expression &lt;<BR>&gt; ?


<BR> is HTML for "a line break", not XML. If you were to insert it, raw, into an XML document then you would just have a start tag for the unknown BR element and no end tag. This would cause the document to be not well-formed and XML parsers to throw a critical error when they encountered the next close tag (which wouldn't be </BR>).

If you want to express a new line as markup, then you need to:

  1. Make sure that the XML application you are using has markup to represent a new line
  2. Create that markup as an element (while there are often methods to insert a chunk of raw XML into a document, they are a good way to accidentally break things and inserting a series of text nodes and elements is safer).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜