× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I've not used XML within PHP much but your 2nd example shows attributes of
an XML elements and not child elements.
Adjusting your research for attributes rather than child elements may put
you on the right path.

Thanks,
Todd Allen
EDPS
Electronic Data Processing Services
tallen@xxxxxxxxxxxx




"Shannon
ODonnell"
<sodonnell@turbog To
orilla-software.c "'Web Enabling the AS400 /
om> iSeries'" <web400@xxxxxxxxxxxx>
Sent by: cc
web400-bounces@mi
drange.com Subject
[WEB400] Getting XML child Elements
PHP
2009-12-09 10:46


Please respond to
Web Enabling the
AS400 / iSeries
<web400@midrange.
com>






Hi,



I have an XML file I need to parse using PHP, and for the most part, I can
parse it fine.



So if I have something like this, it works fine, no problems:





$mydata = simplexml_load_file($FileToOpen);



<batch>

<Report>

<Page1>

<violator_last_name>ZAMBRANO</violator_last_name>

<violator_first_name>FRANK</violator_first_name>

</Page1>

</report>

</batch>



And I can get the data using something like this:



$LastName = $mydata->batch->Report-> Page1->violator_last_name;

$FirstName = $mydata->batch->Report->Page1->
violator_first_name;







However, at the start of certain blocks of data, I have lines like this:



<Report caseID="122" number="000900006S">



The element is <Report> but as you can see, it has child elements of
caseID
and number.



I cannot figure out how to get the values of those child elements.



This does NOT work:



$caseID = $mydata->batch->Report-> caseID;



I have Googled this and looked around but I can't find a solution that
works.





Shannon O'Donnell

--




This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.