Re: [PHP] Reading sub-elements using XML Reader
On Wed, July 18, 2007 4:13 am, Don Don wrote: I am reading the following xml data in a very large file using XML reader, the xml structure looks like the xample given below Any thoughts ? Use simple XML? Or is the file really too huge for that to be feasible? Have you actually tried it?... As a while guess, I'd suggest that maybe $reader-read() will return the next sub-nodes, and you'd do the same thing you're doing now to read the tires... But I've never used XMLReader, and hope I never have to. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading sub-elements using XML Reader
I am reading the following xml data in a very large file using XML reader, the xml structure looks like the xample given below item enginehead/engine braketail/brake tireshead/tires chromespart head 1/chromes chromesPart head 2/chromes seatstail/seats /item item enginehead/engine braketail/brake tireshead/tires chromespart head 1/chromes chromesPart head 2/chromes seatstail/seats /item I can read all elements apart from the sub elements under tires and am kind of looking for a way to read these sub elements. I am using the code structure below $reader = new XMLReader(); $reader-open($feedUrl); while($reader-read()) { switch($reader-nodeType) { case(XMLREADER::ELEMENT): if($reader-localName == engine) { echo $reader-value; } if($reader-localName == brake) { echo $reader-value; } if($reader-localName == tires) { echo $reader-value; //I FIGURE OUT THAT I SHOULD BE ABLE TO READ THE SUB ELEMENTS HERE BUT TRYING TO FIGURE IT OUT } } } Any thoughts ? Cheers - Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.