html - PHP: Auto-generated XML carriage return entities appear w/ SimpleXML and xpath -


I am using SimpleXML and xpath to read the elements from an external UTF-8 XHTML document. I resume the output of Simplex executable XXML () function executed on each element returned with a xpath selector. But the XML Carriage Return Unit is disturbed by every row of my code is inserted There is no extra character in the XHTML document. What is causing this? It seems that the way I'm running through every array element returned from XP . I can not find institutions when I'm just outputting an element straight from SimpleXML (without using Expath).

  & lt ;? Php $ content = new DOMDocument (); $ Content- & gt; LoadHTMLFile (CONTENT.html); $ Story = simplexml_import_dom ($ content-> getElementById ('story')); $ Theme = $ story- & gt; Xpath ('div [@ class = "topic"]'); Forex Currency (subject as $ subject $) {$ topicContents = $ topic- & gt; Xpath ('div / child :: node ()'); // The array of elements within the 'content' foreign currency ($ subject $ content element as content) {$ resonance content element-> AsXML (); }}? & Gt;  

Output with XHTML Carouss Excerpt from XHTML code:

  & lt; Div class = "content" & gt; & Amp; # 13; & Lt; P & gt; Advertisement for the website & lt; / P & gt; & Amp; # 13; & Lt; H2 & gt; Household Advertising & lt; / H2 & gt; & Amp; # 13; & Lt; P & gt; Advertisement for the website & lt; / P & gt; & Amp; # 13; & Lt; Ul & gt; & Lt; Li & gt; Household Advertising & lt; / Li & gt; & Amp; # 13; & Lt; Li & gt; Household Advertising & lt; / Li & gt; & Amp; # 13; & Lt; Li & gt; Household Advertising & lt; / Li & gt; & Amp; # 13;  

In this way, libxml behaves in \ n text nodes.

  & lt;? Php $ xml = & lt; & Lt; & Lt; XML & lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transitional // N" & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt; Title & gt; ... & lt; / Title & gt; & Lt; / Head & gt; K & lt; Body & gt; & Lt; Pre & gt; One \ nb  \ r \ n  c & lt; / Pre & gt; & Lt; / Body & gt; & Lt; / Html & gt; Xml; 
$ content = newdomdocument (); $ Content- & gt; Loadhtml ($ XML); $ Content = simplexml_import_dom ($ content); Copy $ content-> Asxml ();
print
 & lt; Html lang = "en" & gt; & Lt; Head & gt; & Lt; Title & gt; ... & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Pre & gt; A  & amp; # 13;  C & lt; / Pre & gt; & Lt; / Body & gt; & Lt; / Html & gt; 
(\ nThe character "left alone" while \ r \ n is handled as & amp; # 13; \ n)
I'm not an XML expert, but
applications, XML processors are essential, such as the two-sequence sequence #xD #xA and any #xD by translating both, before being transparent on the input, the external passed units (including the document unit) Normalize all line breaks in #xA by a single #xA For Hn.
It should treat \ r \ n as a single \ n but it is not.
If this is not the cause of a serious problem then stay with it. ..


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -