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

Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, bool given #50

Closed vedmant closed 2 years ago

vedmant commented 5 years ago

Hi, I'm trying to use this lib, but at the first try to load XML I have this error: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, bool given

XML:

<?xml version='1.0' encoding="UTF-8" standalone="no" ?>
<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">
<OPS_envelope>
 <header>
  <version>0.9</version>
  </header>
 <body>
  <data_block>
   <dt_assoc>
    <item key="protocol">XCP</item>
    <item key="object">DOMAIN</item>
    <item key="is_success">1</item>
    <item key="attributes">
     <dt_assoc>
      <item key="exp_domains">
       <dt_array>
        <item key="0">
         <dt_assoc>
          <item key="f_let_expire">N</item>
          <item key="expiredate">2019-10-07 16:24:36</item>
          <item key="name">test1.com</item>
          <item key="f_auto_renew">Y</item>
         </dt_assoc>
        </item>
        <item key="1">
         <dt_assoc>
          <item key="expiredate">2019-10-08 20:34:56</item>
          <item key="f_let_expire">Y</item>
          <item key="f_auto_renew">N</item>
          <item key="name">test2.com</item>
         </dt_assoc>
        </item>
       </dt_array>
      </item>
      <item key="page">1</item>
      <item key="total">2</item>
      <item key="remainder">0</item>
     </dt_assoc>
    </item>
    <item key="response_text">Command successful</item>
    <item key="response_code">200</item>
    <item key="action">REPLY</item>
   </dt_assoc>
  </data_block>
 </body>
</OPS_envelope>

PHP: 7.3

kinekt4 commented 3 years ago

Can confirm this. simplexml_load_file doesn't seem to have a problem loading the document.

FluiXML seems to have a problem with the DOCTYPE line

<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">

If you remove it, then it's fine.

daniele-orlando commented 3 years ago

It could be a duplicate of #44. Thanks @kinekt4 for the quick tip. 🙏