0

I need to parse the XML string. When I pass the string to pXML as $this->loadXML($this->xmlString) in the following class, it returns false. What could be the reason for this?

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
};

Here is how I call 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>
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328

1 Answers1

3

You're not parsing the string passed in to pXML, you're attempting to load $this->xmlString which isn't set anywhere. You probably intended $this->loadXML($xml).

What you've got should be giving you a warning, by the way. If it isn't take a look at: How to get useful error messages in PHP?

Community
  • 1
  • 1
user3942918
  • 25,539
  • 11
  • 55
  • 67