Hi all. Glad to have found the community. I have a technical issue with curl I am using it to consume a web service essentially i am sending an http with a set of get variables that then it returns an xml page which is then stored in the $output variable.
what i cannot figure and i know this is very novice of me is how to i get out the specific values i need from the xml.
for instance i can echo it out and it strips the xml or i can use htmlentities in which case it shows the content with the xml but what i don't know is how can i extract specific values from the xml.
I assume i need to parse the xml somehow using simplexml or domxml but i don't fully understand how.
i am familiar with how to do this in for instance actionscript but not in php.
any advise would be very helpful.
I am building a credit check application and i need to store into a mysql database the users negative credit matches in the xml
here is an example of my amateur code
// create curl resource $ch = curl_init();
// set url curl_setopt($ch, CURLOPT_URL, "$url");
//return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string $output = curl_exec($ch);
//echo $output; echo htmlentities($output);
// failed attempt to use xml //$doc = new DOMDocument(); //$doc->loadXML($output); //$responseNode = //$doc->getElementsByTagName("isValidPost")->Name(0); //echo $responseNode; // end of failed attempt
// close curl resource to free up system resources curl_close($ch);
thanks in advance i am glad to have found this place
There might very well be a better way to do this, but recently I had to do something very similar, and used the XMLReader class in order to parse the XML down to the level where the data elements that I needed appeared, and then used the Perl-Compatible Regular Expressions function preg_match() to read the required values.