servo-php / fluidxml

FluidXML, the PHP library for manipulating XML with a concise and fluent API.
BSD 2-Clause "Simplified" License
458 stars 45 forks source link

Importing XML String #30

Closed itsAnuga closed 7 years ago

itsAnuga commented 7 years ago

Feeding FluidXML with a XML string, throws an DOMNode error:

XML looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<document id="d00000" lang="en" format="a4" version="0.1">
  <information>
    <author></author>
    <year></year>
  </information>
  <section-1>
    <topic />
    <section-2>
      <topic />
    </section-2>
  </section-1>
  <section-1>
    <topic />
    <section-2>
      <topic />
      <section-3>
        <topic />
      </section-3>
    </section-2>
  </section-1>
  <section-1>
    <topic />
    <section-2>
      <topic />
      <section-3>
        <topic />
        <section-4>
          <topic />
        </section-4>
      </section-3>
    </section-2>
  </section-1>
</document>

<b>Fatal error</b>:  Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, boolean given in E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidContext.php:216
Stack trace:
#0 E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidContext.php(216): DOMNode-&gt;appendChild(false)
#1 E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidInsertionHandler.php(220): FluidXml\FluidContext-&gt;FluidXml\{closure}(Object(DOMDocument), false)
#2 E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidInsertionHandler.php(335): FluidXml\FluidInsertionHandler-&gt;attachNodes(Object(DOMDocument), Object(DOMNodeList), Object(Closure))
#3 E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidInsertionHandler.php(92): FluidXml\FluidInsertionHandler-&gt;insertIntegerXml(Object(DOMDocument), 0, '&lt;?xml version=&quot;...', Object(Closure), Array)
#4 E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidInsertionHandler.php(26): FluidXml\FluidInsertionHandler-&gt;handleInsertion(Object(DOMDocument), 0, '&lt;?xml ve in <b>E:\tools\help\vendor\servo\fluidxml\source\FluidXml\FluidContext.php</b> on line <b>216</b>

PHP 7.1.2

daniele-orlando commented 7 years ago

Can you post your PHP code please?

itsAnuga commented 7 years ago
<map id="T10062769" lang="en" version="73.4">
    <info>
        <name>Title</name>
        <category>help</category>
        <copyright-years>
            <start>2016</start>
        </copyright-years>
    </info>
    <shortdesc/>
    <section-1>
        <topicref href="t10066540.xml"/>
    </section-1>
    <section-1>
        <topicref href="t10062735.xml"/>
        <section-2>
            <topicref href="t10062722.xml"/>
        </section-2>
    </section-1>
    <section-1>
        <topicref href="t10092866.xml"/>
        <section-2>
            <topicref href="t10098145.xml"/>
        </section-2>
        <section-2>
            <topicref href="t10092865.xml"/>
            <section-3>
                <topicref href="t10103658.xml"/>
            </section-3>
        </section-2>
    </section-1>
</map>
daniele-orlando commented 7 years ago

Uhm, well... great for the XML, but you missed the... PHP code.