Solved

SimpleXML for 4.3

Posted on 2007-04-05
5
599 Views
Last Modified: 2013-12-12
I had a link that I can't find to some code that would act like the new SimpleXML function in php5. Does anyone know of any code that can act like SimpleXML in php 4.3. Specifically it reads the XML string or document and turns it into a PHP Object.
0
Comment
Question by:Isisagate
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Stacy Spear earned 500 total points
ID: 18859383
0
 
LVL 23

Expert Comment

by:Stacy Spear
ID: 18859399
Oops, you did say object. Its already there as XML DOM. Or maybe you need to compile it in if it isn't.

http://us3.php.net/domxml
0
 
LVL 11

Author Comment

by:Isisagate
ID: 18885494
Well the thing is the dom is overly complicated to work with going through all the nodes and such. what I want is this...

<quote>
    <customer>
        <firstname>bob</firstname>
        <lastname>smith</firstname>
    </customer>
    <customer>
         <firstname>Sally</firstname>
         <lastname>Peters</lastname>
    </customer>
</quote>


I want to be able to access it like this....


echo($quote->customer[0]->firstname);  //returns bob
echo($quote->customer[1]->firstname); //returns Sally


I ran across some code that did it once before but I lost the link. Also I have similar code for JavaScript. It just seems like a natural way to access XML especially in a loose typed language.  Kinda like it parses the DOM and builds the objects.
0
 
LVL 23

Expert Comment

by:Stacy Spear
ID: 18888369
Maybe you were referring to the Php (4 something) function of xml_parse_into_struct()?

http://www.google.com/search?q=xml_parse_into_struct%28%29
0
 
LVL 11

Author Comment

by:Isisagate
ID: 18891634
Nope that's not what I had found it literally converted the XML into a PHP Object structure. Not an array structure.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question