Marino Boscolo Neto
Marino Boscolo Neto

Reputation: 71

PHP parse bad-syntaxed XML string containing un-encoded entities

I need to parse 1.000 elements like this one on a single XML string using DOMDocument but it complains about entities and syntax:

    ...
    <sector
      id="2058"
      name="This is an & and it sucks. "
      description="But its worst... there are unencoded/unescaped "quotes" inside attributes as well"
      status="checked">
      <room
         id="8897"
         blabla="xxx"
         visible="true">
           <![CDATA[All is "good" using & here]]>
           <spot>
             Oh no... an & again but &amp; is ok
           </spot>
        </room>
    </sector>
    ...

Do I have to encode entities before loadXML? How do I do that keeping entities already encoded and avoiding to encode tags and real attributes quotes? Is there a way to considering relative good performance to fix this?

Upvotes: 1

Views: 23

Answers (0)

Related Questions