Myron Turner wrote:
Rob Gould wrote:
The problem I'm having is that the XML data that comes back from the
host doesn't just have <eventname> </eventname> tags. It has <f
n="eventname">datahere</f> tags, and I don't know how to get the XML
parser to read the values using that format. (And I don't have
control over the host) As a first step, I just want to retrieve the
"eventname", "venuename", and "venuecity" data from within the
"result" tags at the bottom of the data.
I'm really hoping this is possible with PHP - - - can someone please
steer me in the right direction and tell my what I should change in
the below script? The $tag value is not getting a value string, due
to the XML-data....
Here's my present script:
<?php
$insideitem = false;
$tag = "";
$eventname = "";
$venuename = "";
$venuecity = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $eventname, $venuename, $venuecity;
if ($insideitem) {
$tag = $name;
} elseif ($name == "RESULT") {
echo "found result";
$insideitem = true;
}
}
?>
You'll get these from the attributes array, which is an associative
array:
The third parameter, /attribs/, contains an associative array with
the element's attributes (if any).The keys of this array are the
attribute names, the values are the attribute values.Attribute names
are case-folded
<http://www.php.net/manual/en/ref.xml.php#xml.case-folding> on the
same criteria as element names.Attribute values are /not/ case-folded.
From:
http://www.php.net/manual/en/function.xml-set-element-handler.php
So $venuecity - $attrs['venuecity'], etc.
--PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I misread your original xml. It seems that your attribute names are "n"?
n="eventname"
Then it's n which will be the key in the attributes array:
$attrs['n'].
Perhaps it would help if you gave use the actual xml and not just this
schematic. The file your refer us to can't be downloaded.
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php