• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

PHP SimpleXML problem

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
arthrex
Asked:
arthrex
  • 2
1 Solution
 
Roger BaklundCommented:
Try this:
$isError = $processingResult[0] -> FunctionResult;

Open in new window

0
 
Roger BaklundCommented:
Did my answer not resolve your issue?

http://www.experts-exchange.com/help.jsp#hi403
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now