I am reading an XML file in that is returned to me from a SOAP webservice call (yeah yeah I don't like SOAP either). And I'm using PHP's SAX functions to parse the document that I get back, and I want to build an HTML table based on certain tags. My question is this: Is there some kind of global or built-in variable that I can look at from my function that gets passed to the parser's xml_set_character_data_handler callback? Right now my really simple code looks like this:
Code: Select all
function startTag($xmlParser, $tag, $attrs)
{
if($tag == 'dat:basePrice')
{
echo '<tr>';
}
}
function endTag($xmlParser, $tag)
{
if($tag == 'dat:basePrice')
{
echo '</tr>';
}
}
function dataHandler($xmlParser, $data)
{
echo '<td>'.htmlspecialchars($data).'</td>';
}
$xmlParser = xml_parser_create();
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($xmlParser, 'startTag', 'endTag');
xml_set_character_data_handler($xmlParser, 'dataHandler');
xml_parse($xmlParser, $responseEnvelope, true);
xml_parser_free($xmlParser);Can someone help me out??