Read XML with PHP

Posted by sea_1987 on Stack Overflow See other posts from Stack Overflow or by sea_1987
Published on 2010-04-30T16:04:49Z Indexed on 2010/04/30 16:07 UTC
Read the original article Hit count: 326

Filed under:
|
|

I am trying to check a field in some XML that is returned from an outside. The XML is returned in a variable call $out and when you view the source of the page you get a XML output of the following,

<?xml version="1.0" encoding="UTF-8"?>
<ResponseBlock Live="FALSE" Version="3.51">
  <Response Type="AUTH">
    <OperationResponse>
      <TransactionReference>23-9-1334895</TransactionReference>
      <TransactionCompletedTimestamp>2010-04-30 15:59:05</TransactionCompletedTimestamp>
      <AuthCode>AUTH CODE:TEST</AuthCode>

      <TransactionVerifier>AlaUOS1MOnN/iwc5s2WPDm5ggrCLwesUnHs9h+W0N3CRaln2W6lh+6dtaRFFhLdwfnw6y7lRemyJUYl9a3dpWfzORE6DaZkFMb+dIb0Ne1UxjFEJkrEtjzx/i8KSayrIBrT/yGZOoOT42EZ9loc+UkdGk/pqYvj8bZztvgBNo2Ak=</TransactionVerifier>
      <Result>1</Result>
      <SettleStatus>0</SettleStatus>
      <SecurityResponseSecurityCode>1</SecurityResponseSecurityCode>
      <SecurityResponsePostCode>1</SecurityResponsePostCode>
      <SecurityResponseAddress>1</SecurityResponseAddress>

    </OperationResponse>
    <Order>
      <OrderInformation>This is a test order</OrderInformation>
      <OrderReference>Order0001</OrderReference>
    </Order>
  </Response>
</ResponseBlock>

I want check what value is in the 'Result' field. I am unsure how to access the information using PHP, so far I have,

$xml = simplexml_load_string($out);

Many Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml