xml parsing problems

From: Date: Tue, 22 Oct 2002 18:02:30 +0000
Subject: xml parsing problems
Groups: php.general 
Request: Send a blank email to php-general+get-120956@lists.php.net to get a copy of this message
hello, i'm parsing an xml file using php's native xml functions. running php on mac osx 10.2 - using version 4.2.3 i've been using the function called characterData to gather data from the xml nodes. it looks like this: function characterData($parser,$chardata) { global $current_tag; if($current_tag=='head') echo "<p class=\"bclabel\">"; // strip leading and trailing whitespace if($chardata!="\n" && $chardata!=" " && $chardata!="\t") { if($current_tag=='category'){ echo "<a name=\"".$chardata."\">".$chardata; } else if($current_tag=='menu') { echo "<a href=\"#".$chardata."\">".$chardata."</a>"; } else { echo $chardata; } } } this function has outcomes that i find to be unusual. the section of the document that i'm having trouble with looks like this. <menulist> <menu>2D Nodes</menu> <menu>Spreads</menu> <menu>Direct Show</menu> <menu>GUI</menu> <menu>Animation</menu> </menulist> now, some nodes have more than two words, which i did not think would be a problem for the function. however, there still appears to be some whitespace and one of the two-word nodes (but not both) has been split up into two different anchor links: <a href="#2D Nodes">2D Nodes</a></h2></td></tr> <a href="# "> </a><tr><td class="Col-02" colspan="3"><a href="#Spreads">Spreads</a></h2></td></tr> <a href="# "> </a><tr><td class="Col-02" colspan="3"><a href="#Direct ">Direct </a><a href="#Show">Show</a></h2></td></tr> <a href="# "> </a><tr><td class="Col-02" colspan="3"><a href="#GUI">GUI</a></h2></td></tr> <a href="# "> </a><tr><td class="Col-02" colspan="3"><a href="#Animation">Animation</a></h2></td></tr> i'd certainly appreciate it if anybody could lend me an hand here and indicate what i'm doing incorrectly. thanks! jeremy

« previous php.general (#120956) next »