Solved

SimpleXML for 4.3

Posted on 2007-04-05
5
595 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now