Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Using PHP to parse specific XML tag content? [Thread Next] Re: Using PHP to parse specific XML tag content?To: NULL Date: 12/2/2008 8:31:00 AM On Dec 2, 10:01=A0am, "=C1lvaro G. Vicario" <alvaroNOSPAMTHA...@demogracia.com> wrote: > Mechphisto escribi=F3: > > > I'm trying to write a PHP script that will grab the info from an XML > > file, and parse and sort the data into their own variables. > > Can someone point me a direction for information? > [...] > > $xml_parser =3D xml_parser_create(); > > xml_set_element_handler($xml_parser, "startTag", "endTag"); > > xml_set_character_data_handler($xml_parser, "contents"); > > I wrote an XML parser a few years ago and it's not something I'd like to > repeat. While parsing you must keep track of where you are (inside a > tag? which tag?) and you have to deal with stuff like "What if > contents() doesn't return the whole contents because fread() stopped in > the middle?". There're many tools nowadays that avoid you the boring > internals. > > You can use any of the built-in libraries: > > http://es.php.net/manual/en/refs.xml.php > > Some people love SimpleXML. I've found XMLReader quite usable. There's > even a user note with the code you want to write: > > http://es.php.net/manual/en/class.xmlreader.php#87288 > > Or you can use third-party code. I specially enjoy phpQuery: > > http://code.google.com/p/phpquery/ Thanks, I appreciate the the reply and suggestions. That XMLReader does look like what I could use. Unfortunately, I'm on a shared server host and don't have control over what libraries can be installed into PHP. So, I'm kind of stuck with whatever solution is default built-in PHP5. Thanks, though. :) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
