[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP SimpleXML problem

Posted on 2008-11-13
2
Medium Priority
?
314 Views
Last Modified: 2012-05-05
Hi experts,

I try to read xml data from an XML response by using  the SimpleXMLElement.
But it doesn't work. When I write the output to a file I can see the response,
but when I try to read single Elements (i.e. FunctionResult) it's always empty.

Where's the mistake?
//THE XML RESPONSE
 
<?xml version="1.0" encoding="UTF-8"?> 
<WIRECARD_BXML xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:noNamespaceSchemaLocation="wirecard.xsd"> 
<W_RESPONSE> 
  <FNC_CC_TRANSACTION> 
    <PROCESSING_STATUS> 
      <GuWID>C888752122656993575722</GuWID>
      <AuthorizationCode></AuthorizationCode> 
      <Info>THIS IS A DEMO TRANSACTION </Info> 
      <StatusType>INFO</StatusType> 
      <FunctionResult>NOK</FunctionResult> 
      <ERROR> 
        <Type>DATA_ERROR</Type> 
        <Number>20071</Number> 
        <Message>Expiration date invalid.</Message> 
        <Advice>Expiration date must not be exceeded.</Advice> 
       </ERROR> 
     </PROCESSING_STATUS> 
   </FNC_CC_TRANSACTION>  
 </W_RESPONSE> 
</WIRECARD_BXML>
 
//MY PHP Script (outpou
	  $xml = new SimpleXMLElement($output);
	  
	  $processingResult = $xml -> xpath('//PROCESSING_STATUS');
	  $isError = $processingResult -> FunctionResult;
	  
	  $errorMessage = "";
	  $errorAdvice = "";
	  
	  echo "isError".$isError; //echo just displays "isError" 
                                   //($isError seems to be empty)
 
<TimeStamp>2008-11-13 10:52:15</TimeStamp>

Open in new window

0
Comment
Question by:arthrex
  • 2
2 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 1500 total points
ID: 22948506
Try this:
$isError = $processingResult[0] -> FunctionResult;

Open in new window

0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 22949167
Did my answer not resolve your issue?

http://www.experts-exchange.com/help.jsp#hi403
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question