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
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.
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
$dom = new DOMDocument; //load the XML string into the dom//
$dom->loadXML( $xml ); $sxe = simplexml_import_dom($dom); //Lets display the value
Hey Caspian, Without seeing the whole script it hard to say where the problem is, but I emailed you an example of what you want to do that works. If you have any other issues let me know.
Hello Travis & Caspian,
I'm working on a PHP script to pull performance info for a simple calendar. I found Travis's post at http://www.tessituranetwork.com/Community/forums/t/10528.aspx to be very helpful, and using the cURL method my script is able to obtain a session ID from the API.
However, I can't seem to get any other methods to work. For example, trying GetPerformancesEx to find all shows in a given venue between set start and end dates (which is what I need to do). Just like with the session ID, I'm using cURL to request a URL with all my parameters as GET vars. First I got a 400 error, "Badly formed request." Then I tried using urlencode on the URL before passing it to cURL and then I got a cURL error, "Cannot resolve host."
Caspian, you say you have been able to get performance data using cURL. Have you experienced these issues? I'd love to see an example cURL request that works for you. I can also share my code here if either of you feel like seeing what I'm doing wrong.
Thanks in advance!
Chris
Hey Chris, Send me the script and I will take a look at it sometime tonight or tomorrow.
From: Tessitura Web Forum [mailto:forums-tessitura-web@tessituranetwork.com] On Behalf Of Christian Bisgard Sent: Friday, March 07, 2014 4:04 PM To: Travis Armbuster Subject: Re: [Tessitura Web Forum] Reading XML in PHP... :(
From: Travis Armbuster <bounce-travisarmbuster9061@tessituranetwork.com> Sent: 2/21/2014 9:28:04 AM
You were sent this email automatically because you subscribed to the Tessitura Web forum. You may reply to this message to post to the Web forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!
Thanks very much! Do you prefer I send it by email?
Sure, travisa@arenastage.org