Re: I must be an XML parser idiot

From: Date: Thu, 28 Oct 2004 19:23:45 +0000
Subject: Re: I must be an XML parser idiot
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200570@lists.php.net to get a copy of this message
On Thu, 2004-10-28 at 14:26, Jay Blanchard wrote: > Good afternoon gurus and gurettes! > > ***** example code ***** > /* functions for XML parser */ > function dataHandler($parser, $data){ > echo $data . "<br>\n"; > } > function StartTag($parser, $name, $attribute){ > if("servicebrandname" == $name){ > echo "-----<br>\n"; > } > } > function EndTag($parser, $name){ > if("servicebrandname" == $name){ > echo "-----<br>\n"; > } > } > > /* create a parser */ > if(!($covadParser = xml_parser_create())){ > echo "Failed to create parser<br>\n"; > exit(); > } > /* set handlers for parser */ > xml_set_character_data_handler($covadParser, "dataHandler"); > xml_set_element_handler($covadParser, "StartTag", "EndTag"); > > /* let's parse! */ > if(($readXML = fopen("/usr/feynman/ADHOC/covad/testRecp.xml", "r"))){ > while($lineXML = fread($readXML, 1024)){ > echo $lineXML; > xml_parse($covadParser, $lineXML, TRUE); > } > } > ***** end code ***** > > I expect what I get back to look like.... > TeleSurfer DSL+IP - Shared Line (Professional-Install) > SOHO Internet Access 6.0/768 (Self-Install) > > But it is not coming back this way. Do I posess a fundamental > misunderstanding of the way the xml parser is supposed to work? Could you send an XML sample please. And the output that you do get for it. Without those it's hard to say. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#200570) next »