xml element exists
Posted on
16th Feb 2014 07:03 pm by
admin
Code: [Select]<?xml version="1.0"?>
<Addresses>
<Address ID="1">
<Address2>101 MAIN ST</Address2>
<City>BIGTOWN</City>
<State>OH</State>
<Zip5>22222</Zip5>
<Zip4></Zip4></Address>
<Address ID="2">
<Address2>420 HIGH ST</Address2>
<City>MYTOWN</City>
<State>AK</State>
<Zip5>54321</Zip5>
<Zip4>2562</Zip4></Address>
</Addresses>
My code is reading the above xml, but if there was an error the xml will be different, for example:
Code: [Select]<?xml version="1.0"?>
<Addresses>
<Address ID="1">
<Error>
<Number>-2147219401</Number>
<Source>blah</Source>
<Description>Address Not Found. </Description>
<HelpFile></HelpFile>
<HelpContext>1000440</HelpContext>
</Error>
</Address>
<Address ID="2">
<Address2>420 HIGH ST</Address2>
<City>MYTOWN</City>
<State>AK</State>
<Zip5>54321</Zip5>
<Zip4>2562</Zip4></Address>
</Addresses>
Currently, I am accessing the elements like this:
$xml = new SimpleXMLElement($xml_txt);
$first_address = $xml->Address[0]->Address2;
$second_address = $xml->Address[1]->Address2;
This code doesn't work when the error xml is returned. There will always be 2 items in the xml. How can I tell which (if any) address has an 'error' node? Also, I need to know which of the 2 IDs has the error.
No comments posted yet
Your Answer:
Login to answer
159
46
Other forums
Undefined variable when using $_SERVER['PHP_SELF']
Hi guyz, please suggest me something...
On first.php I have one input field NAME, and on posting
Material Issuing for receiving batch
Dear All experts in MM/ PP,
Material issuing from main stores to factory is currently usi
Agency Business Process
Hi,
I don’t understand the process of the agency business in SAP.
In my
preg_match logical error
Code: <?php
$s = file_get_contents("page.html");
preg_match('/<div cla
Save data in input fields when they press "BACK BUTTON"
Hi, this is html form: And let's say they get a error "Please enter ur title must be more then
how can i display php source code snippets ?
I am outputting some pho code .. and I want to display the source code so people can copy and paste
sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the
How to generate a text file using php...?
Hi,
Can anyone give me code to generate a text file using php
Thanks in advance
Vertical Alligning - Not working in 1 cell?
<?php
echo "<table id="valign" width="60%" style=
Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very