[UPHPU] parsing XML
lists at kittypee.com
Thu Feb 25 17:02:54 MST 2010
On Thu, Feb 25, 2010 at 4:10 PM, Wade Preston Shearer
<wadeshearer.lists at me.com> wrote:
> I am working with GoEmerchant's XML Gateway. The responses are returned as XML. A simple way to convert this into usable information is using simplexml_load_string() (part of the SimpleXML extension). This isn't working for me however since it returns each node with a numbered index and since GoEmerchant's responses are different depending on the type of transaction and whether it is successful or not, I cannot address the nodes by their order (or index) or might grab the wrong one.
SimpleXML provides an XPath interface that you can use to search for
the node containing the status.
$xml = simplexml_load_string($string);
$array = $xml->xpath("//field[@key='status']");
$status = $array;
or something like that.
More information about the UPHPU