Re: modify xml before parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeo Wee Tat wrote:
Hi Adam,

  I can modify the xml file without any error , however when I tried to
unserializer the xml file using PEAR:XML , it gave the error message below.
I have attached my code for your perusal. Any ideas ? thanks
<?php
ini_set('display_errors', E_ALL);
require_once '../library/config.php';
require_once '../library/class.XMLUtil.php';

$xmlfile = "/home/gvintranet/datacraft/htdocs/uploads/cisco.xml";

$xml = preg_replace("/<!\\[CDATA\\[.+?\\]\\]>/", "<![CDATA[ignore_this]]>",
$xml);
$filehandle = fopen($xmlfile, 'wb');
$ok = fwrite($filehandle,$xml);
echo "ok".$ok;

$options = array("complexType" => "object");
$xml_util = new XMLUtil($xmlfile, $options);
$xml_util->unserializer_XML(true);
$data = $xml_util->getUnserializedData();
echo print_r($data);

?>

error message:

pear_error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024
[code] => 151 [message] => No unserialized data available. Use
XML_Unserializer::unserialize() first. [userinfo] => [backtrace] => Array (
[0] => Array ( [file] => /usr/share/pear/PEAR.php [line] => 566 [function]
=> pear_error [class] => pear_error [type] => -> [args] => Array ( [0] => No
unserialized data available. Use XML_Unserializer::unserialize() first. [1]
=> 151 [2] => 1 [3] => 1024 [4] => ) ) [1] => Array ( [file] =>
/usr/share/pear/XML/Unserializer.php [line] => 489 [function] => raiseerror
[class] => xml_unserializer [type] => -> [args] => Array ( [0] => No
unserialized data available. Use XML_Unserializer::unserialize() first. [1]
=> 151 ) ) [2] => Array ( [file] =>
/home/gvintranet/datacraft/htdocs/library/class.XMLUtil.php [line] => 54
[function] => getunserializeddata [class] => xml_unserializer [type] => ->
[args] => Array ( ) ) [3] => Array ( [file] =>
/home/gvintranet/datacraft/htdocs/admin/test_regex.php [line] => 43
[function] => getunserializeddata [class] => xmlutil [type] => -> [args] =>
Array ( ) ) ) [callback] => ) 1

Yeo Wee Tat Tel: +65-62730049 Fax: +65-62734934
Cxrus Solutions Pte Ltd (Singapore . Thailand)
1003 Bukit Merah Central #05-20 Singapore 159836
System Integration . Business Solutions . Linux Simplified
I must admit, I've never used Pear for anything (I stick to SimpleXML myself). Perhaps it doesn't like the new cdata tag you're writing? Have you tried replacing the entire cdata tag with an empty string, or trying another XML parser (like SimpleXML) just to see if the trouble is with your XML or Pear?

Regards, Adam.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux