0
我需要解析XML字符串。當我在下面的類中將字符串傳遞給pXML
作爲$this->loadXML($this->xmlString)
時,它將返回false
。這可能是什麼原因?loadxml返回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>
你的XML很可能已經壞了,是否足夠小以便分享? – hoppa
@hoppa我已經分享了這個xml。 –
你可以給你的問題添加'$ this-> loadXML'方法嗎? '$ this-> xmlString'是一個有效的xml字符串嗎? –