Hello, I am using simplexml_load_string() function. I am having an issue extracting values. I am able to print_r($xml); and return the following:
SimpleXMLElement Object ( [0] => 31292 378 705595 Mr. Graham bgraham@arenastage.org 7002 5 Declined N 0 AF14-ON 1 Velocity Show 2014 me and my friends )
The source appears as follows:
SimpleXMLElement Object( [0] => <ExecuteLocalProcedureResults> <LocalProcedure> <evex_no>31292</evex_no> <campaign_no>378</campaign_no> <customer_no>705595</customer_no> <lsal_desc>Mr. Graham</lsal_desc> <email_address>bgraham@arenastage.org</email_address> <source_no>7002</source_no> <inv_status_id>5</inv_status_id> <invitation_status>Declined</invitation_status> <reserve_ind>N</reserve_ind> <num_attendees>0</num_attendees> <notes xml:space="preserve"> </notes> <campaign_name>AF14-ON 1 Velocity Show</campaign_name> <fyear>2014</fyear> <source_name>me and my friends</source_name> </LocalProcedure></ExecuteLocalProcedureResults>)
OK now to the point....
I would like to know why print_r($xml->campaign_name) will not work and how to extract the values.I am sure that I am missing something. I know enough PHP to get into trouble, but have hit a wall with this issue. Side note: I am able to extract the values using sub string, but that can't be the best, right, or most efficient way to extract the values.
example:
$xml = simplexml_load_string($response);
print_r($xml->campaign_name);
Any help/ideas would be awesome!
Thanks,
Travis
Hi Travis,
Hope you are well!
Was just wondering if I could pick your brains again on a XML PHP query.
Using the cURL method you showed me previously I've been successfully obtaining Production and Performance information but have been unable to obtain the boolean value from logging in as a user and authenticating a session.
The way I'm trying to do this currently is as follows:
$response2 = curl_exec($login);
$xmlContent = simplexml_load_string($response2);
if(curl_errno($login))
{
echo 'Curl error: Unable to login ' . curl_error($login);
}
else {
foreach($xmlContent->xpath('boolean') as $bool) {
echo $bool;
if ($bool=='true'){
echo'test';
header("Location: GetAccountDetails.php");
From: Travis Armbuster <bounce-travisarmbuster9061@tessituranetwork.com> Sent: 8/10/2013 4:50:45 PM
OK... I got it. Apparently I need to normalize the nodes. You can achieve this by using DomDocument. This acts as if you saved and loaded the file, putting the document in "normal" form. Here is the code that I have to extract the XML value.
Example:
//Load the XML string
//Create a new doc
$dom = new DOMDocument; //load the XML string into the dom//
$dom->loadXML( $xml ); $sxe = simplexml_import_dom($dom); //Lets display the value
echo $sxe->LocalProcedure[0]->campaign_name;
By using the code above I can now extract the values I want ( YAY!!!!!!). Hope this helps someone else out.