Forum Moderators: coopster

Message Too Old, No Replies

parsing out this xml via php?

is it possible?

         

bessington

1:36 am on Aug 9, 2005 (gmt 0)

10+ Year Member




is it possible to parse out an xml document that is structured as follows (i did not write this xml file!) :

<gallery>
<album id="3" title="mainpage" description="Zeek's Creek." lgPath="http://site.com" tnPath="" tn="http://site.com/" startHere="">
<img src="zekes creek.jpg" caption="" link="zekes creek.jpg"/>
</album>
</gallery>

so that i can return just the value of the album description via php under the picture? or is this xml file actually not considered a true xml file based on the multiple attributes? thank you!

-bessington

phpmattk

4:40 am on Aug 9, 2005 (gmt 0)

10+ Year Member



Wether it is valid or not shouldn't matter, you can grab the data, and parse it like a regular string. You can use regexp, which is way to much to go into here, or you could simply use strpos(), to find the first occurence of description=" then starting there find the next occurence of " then use substr() to grab the piece of text between description=" and "

bessington

10:17 pm on Aug 13, 2005 (gmt 0)

10+ Year Member



I am a bit new to xml parsing.. so pardon my my potentially confusing logic.

i've found a routine to convert an XML file into a PHP structure. I am not sure once it parses the file how to grab the instances of the structure i need.. a variable called $obj->xml, contains the php structure. Here is an example of what it prints out:

stdClass Object ( [GALLERY] => stdClass Object ( [data] => [ALBUM] => Array ( [0] => stdClass Object ( [attr] => Array ( [ID] => 1 [TITLE] => Studio Paintings [DESCRIPTION] => Studio Paintings by Mark Fernandez.

How do I from this point, just grb the Description array as a value and then just print that out? Thank you - and help is greatly appreciated!

bessington

9:52 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



anyone have any thoughts on this? Thank you!

-bess