Jump to content

PHP + XML help


speedy33417

Recommended Posts

I'm working on a website that deals with an xml response. After an application is filled out on our website we get a response sent to us in $result

 

If the application is approved then it looks something like this:

 

<tss_loan_response><signature><data name="page">app_completed</data><data name="site_type">soap_oc</data><data name="license_key">sample</data><data name="promo_id">99999</data><data name="promo_sub_code"/></signature><errors/><content><section><verbiage><![CDATA[<br/>
<p>Thank you for your application. You have been approved. Please click <b><a href="http://www.somesite.com">here</a></b>to complete your application.</p><p>You will be automatically sent to the page in a few seconds.</p><script type="text/javascript">
var script_expression = "document.location.href = 'http://www.somesite.com'";
var msecs = 2 * 1000; setTimeout(script_expression, msecs);</script>
]]></verbiage></section></content></tss_loan_response>

 

 

I need pieces of code from the $result

 

1.  The code between <data name="page"> and </data>

2.  The code between <![CDATA[  and  ]]>

 

How would I get them in $page and $data???

Link to comment
https://forums.phpfreaks.com/topic/170695-php-xml-help/
Share on other sites

I'd write you out something but I'm really tired right now and I'm going to bed. But here's a tutorial that should help you a lot.

 

http://www.phpfreaks.com/tutorial/handling-xml-data

 

You'll probably have to use $tss_loan_response->content->section->verbiage for the cdata.

Link to comment
https://forums.phpfreaks.com/topic/170695-php-xml-help/#findComment-900270
Share on other sites

Thanks Darken.

 

I looked at the tutorial, but it's still not clear how I can get those two pieces of code that I need to display for the applicant.

 

I've never dealt with XML and it's totally new territory for me. I was hoping that I could maybe use regex to fish out the part that I need or any simple solution that would load the required part of the script into my variables.

 

Anybody else, pleeeeeeaaaaase?

Link to comment
https://forums.phpfreaks.com/topic/170695-php-xml-help/#findComment-900274
Share on other sites

Try this out. >.< Kept thinking about it in bed. ;D

 

$xml = SimpleXMLElement($xmlfile, null, true);

echo "Data: " . $xml->xpath("tss_loan_response/data[@name=\"site_type\"]")->nodeValue . "<br />\n";
echo "CData: " . $xml->tss_loan_response->content->section->verbiage->nodeValue;

Link to comment
https://forums.phpfreaks.com/topic/170695-php-xml-help/#findComment-900284
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.