DOMXML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Davey
Forum Newbie
Posts: 7
Joined: Sun May 26, 2002 10:49 pm

DOMXML

Post by Davey »

OK... I'm trying to learn how to use DOM.
Unfortunately... it's just NOT getting through. I've read a few tutorials... but they're old and well, I've gotten lost.

What I need is either a bang up-to-date tutorial, OR someone to supply with some PHP code which I can pick apart. I need to parse XML to get what attributes exist in a node, the attribute values, and to like... "select" certain nodes based on an attributes value. All my XML is like this:

Code: Select all

<data attr1="val1" attr2="val2 />
rather than:

Code: Select all

<date>
<attr1>val1</attr1>
<attr2>val2</attr2>
</date>
- Davey
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

do you want to know how to do it in general or how to in php?
if the latter (which is more likely since your post is in the php-forum ;) )take a look at CV. XML parser functions and (probably more of interest) xml_set_element_handler where you can specifiy a start_element_handler ( resource parser, string name, array attribs) function.
Depending on what you want to achieve CVII. XSLT functions might be thrilling, too.
Davey
Forum Newbie
Posts: 7
Joined: Sun May 26, 2002 10:49 pm

Post by Davey »

Thanks for your response... I *really* want to use DOM for this.... I have read and considered the merits of SAX, DOM and PRAX and DOM is my choice... I just need to get my head around it.

- Davey
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

then I suggest http://www.xmlfiles.com/ and (not a tutorial page) http://www.w3.org/TR/

keep in mind [http://www.php.net/manual/en/ref.domxml.php]
The DOM XML extension has been overhauled in PHP 4.3.0 to better comply with the DOM standard. The extension still contains many old functions, but they should no longer be used. In particular, functions that are not object-oriented should be avoided.
Post Reply