I create an XML in PHP Zend framework using DOM Class. To put a new line in XML element textnode an expression <<BR>>
is passed. But when I pass a string with <<BR>>
the generated XML will have &lt;BR&gt;
instead actual expression <<BR>>
. and so, the display of data from XML will print <BR>
instead of new line.
How to prevent modification of t开发者_运维问答he expression <<BR>>
?
<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:
- Make sure that the XML application you are using has markup to represent a new line
- 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).
精彩评论