Parsing XML from an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

Parsing XML from an array

Post by empiresolutions »

i am trying to figure out how to remove the xml from a php array. when i run the following script,

Code: Select all

exec("/usr/bin/curl -m 120 -d \"xml=$xmlstring\" https://site_name.net/gateway_v2.php -L", $response);


$responce comes back almost correct. when i do a print_r() i get,

Code: Select all

Array
	(
		[0] => 
		[1] =>   
		[2] =>     direct
		[3] =>     2
		[4] =>     charge
		[5] =>     7.318 sec
		[6] =>   
		[7] =>   
		[8] =>     
		[9] =>       1362610
		[10] =>       541 - 48f53277f7552953e633c49d62eb44ef
		[11] =>       Amount successful authorized
		[12] =>     
		[13] =>   
		[14] => 
		[15] => 
	)


but when i view source i get,

Code: Select all

Array
	(
		[0] => <epxml>
		[1] =>   <header>
		[2] =>     <responsetype>direct</responsetype>
		[3] =>     <mid>2</mid>
		[4] =>     <type>charge</type>
		[5] =>     <ptime>5.332 sec</ptime>
		[6] =>   </header>
		[7] =>   <response>
		[8] =>     <success>
		[9] =>       <tan>1363022</tan>
		[10] =>       <etan>59 - 5e6ae161c8a80ea5d79408dca41eed60</etan>
		[11] =>       <message>Amount successful authorized</message>
		[12] =>     </success>
		[13] =>   </response>
		[14] => </epxml>
		[15] => 
	)


i need to strip the xml from the array. please help
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Do you really want to strip the xml? Because when you strip A from A you end up with nothing..
I'm pretty sure http://www.php.net/xml_parse_into_struct will be able to help you :)
Post Reply