cimmer
asked on
In PHP4 versus PHP5, use simplexml, domxml or xml?
Im creating a script that pulls xml data from a central server, then stores it locally to be read. The script will resides on 100's of different servers. Some of these servers have php4, some have php5, some have domxml, some have simplexml, some have regular xml... Ive done what i needed to in domxml and in simple xml... My question is does anyone have a easy way to match the following examples...
CODE EXAMPLE 1: SERVER WITH SIMPLEXML RUNS...
$domaininfo = simplexml_load_file($local xmlfile);
CODE EXAMPLE 2: SERVER WITH DOM XML RUNS...
$xml = file_get_contents($localxm lfile);
$doc = domxml_open_mem($xml); //(PHP 4 >= 4.2.0)
$domaininfo = xmlnode2array($doc->root() );
I need domaininfo to be an array containing the xml data... the xml data has children, its not just one level deep... heres an example of the data being pulled...
EXAMPLE XML:
<domaininfo>
<nid>378</nid>
<title>Best+Web</title>
<created>1212617890</creat ed>
<changed>1212799071</chang ed>
<url>http://www.domain.com</url>
<flash_header>
<nid>376</nid>
<title>Digital+Media+2</ti tle>
<created>1212617812</creat ed>
<changed>1212787780</chang ed>
<movie>
/flash/flas2.swf
</movie>
<checksum>fb539422b5f4cbd1 e0b1437f98 859857</ch ecksum>
<size>529991</size>
<width>780</width>
<height>300</height>
</flash_header>
<style_sheet>
<nid>370</nid>
<title>Basic</title>
<created>1212612552</creat ed>
<changed>1212788566</chang ed>
<style>
some style sheet code
</style>
</style_sheet>
<pages>
<page>
<nid>379</nid>
<title>Media+Design</title >
<field_weight>2</field_wei ght>
<url>mediadesign.html</url >
</page>
<page>
<nid>380</nid>
<title>Design+Services</ti tle>
<field_weight>0</field_wei ght>
<url>designservices.html</ url>
</page>
<page>
<nid>381</nid>
<title>Design+Tools</title >
<field_weight>5</field_wei ght>
<url>graphic-design-tools. html</url>
</page>
</pages>
</domaininfo>
WHAT I NEED:
i need a NON domxml and NON simplexml example that will work in php4 of how to convert xml into an array... can you help point me in the right direction and/or provide an example??
CODE EXAMPLE 1: SERVER WITH SIMPLEXML RUNS...
$domaininfo = simplexml_load_file($local
CODE EXAMPLE 2: SERVER WITH DOM XML RUNS...
$xml = file_get_contents($localxm
$doc = domxml_open_mem($xml); //(PHP 4 >= 4.2.0)
$domaininfo = xmlnode2array($doc->root()
I need domaininfo to be an array containing the xml data... the xml data has children, its not just one level deep... heres an example of the data being pulled...
EXAMPLE XML:
<domaininfo>
<nid>378</nid>
<title>Best+Web</title>
<created>1212617890</creat
<changed>1212799071</chang
<url>http://www.domain.com</url>
<flash_header>
<nid>376</nid>
<title>Digital+Media+2</ti
<created>1212617812</creat
<changed>1212787780</chang
<movie>
/flash/flas2.swf
</movie>
<checksum>fb539422b5f4cbd1
<size>529991</size>
<width>780</width>
<height>300</height>
</flash_header>
<style_sheet>
<nid>370</nid>
<title>Basic</title>
<created>1212612552</creat
<changed>1212788566</chang
<style>
some style sheet code
</style>
</style_sheet>
<pages>
<page>
<nid>379</nid>
<title>Media+Design</title
<field_weight>2</field_wei
<url>mediadesign.html</url
</page>
<page>
<nid>380</nid>
<title>Design+Services</ti
<field_weight>0</field_wei
<url>designservices.html</
</page>
<page>
<nid>381</nid>
<title>Design+Tools</title
<field_weight>5</field_wei
<url>graphic-design-tools.
</page>
</pages>
</domaininfo>
WHAT I NEED:
i need a NON domxml and NON simplexml example that will work in php4 of how to convert xml into an array... can you help point me in the right direction and/or provide an example??
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
-Ray