Solved

SimpleXML for 4.3

Posted on 2007-04-05
5
600 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

695 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