loadxml returns false:可能是什么原因?

loadxml returns false: what could be the reason for it?

我需要解析 XML 字符串。当我在下面的 class 中将字符串作为 $this->loadXML($this->xmlString) 传递给 pXML 时,它 returns false。这可能是什么原因?

class MXML extends DOMDocument {

        private $version,$encodingType,$rootNode,$videoParam,$encodingFormat,$audioParam,$xmlString;

        /**
         * Initilizes the DOM with version number and encoding
         * @param  $version
         * @param  $encoding
         */
        public function __construct($version,$encoding) {
            parent::__construct($version,$encoding);
            $this->formatOutput = true; // Nicely formats output with indentation and extra space.
        }

        public function pXML($xml) {
            $this->loadXML($this->xmlString); // returns FALSE
            $parameters = $this->getElementsByTagName("Parameter");
            $advanced = $this->getElementsByTagName("Advanced");
            $preprocessing = $this->getElementsByTagName("Preprocessing");
        }

        //..  write xml functions
};

我是这样称呼 pXML:

$xml = new MXML();
$xml->pXML($result['XMLSettings']);

XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<Cutkompress-Parameters>
  <Video-Params>
    <EncodingFormat-MPEG-4Part2>
      <Parameter>
        <IQuant>7</IQuant>
        <PQuant>7</PQuant>
        <FramesToSkip>7</FramesToSkip>
        <PBetweenI>7</PBetweenI>
        <FrameRate>7</FrameRate>
        <SearchWindow>7</SearchWindow>
      </Parameter>
      <Advanced>
        <QuantType>7</QuantType>
        <QPel>ON</QPel>
        <MV>ON</MV>
        <SceneChange>Detect Medium Change</SceneChange>
        <VOL_Control_Parameters>ON</VOL_Control_Parameters>
      </Advanced>
      <Preprocessing>
        <NoiseReduction>Detect Medium Change</NoiseReduction>
        <SharpnessLevel>7</SharpnessLevel>
      </Preprocessing>
    </EncodingFormat-MPEG-4Part2>
  </Video-Params>
</Cutkompress-Parameters>

您没有解析传递给 pXML 的字符串,您正在尝试加载未在任何地方设置的 $this->xmlString。您可能打算 $this->loadXML($xml).

顺便说一句,你得到的应该是给你一个警告。如果不是,请查看:How to get useful error messages in PHP?