× 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.



Shannon,

I think you need to use:

$caseID = $mydata->batch->Report['caseID'];

I'm not where I can test it, but I think that is the syntax for retrieving
attributes.

Brian May
Project Lead
Management Information Systems
Garan, Incorporated
Starkville, Mississippi

Young i Professionals
http://www.youngiprofessionals.com



"Shannon ODonnell" <sodonnell@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sent by: web400-bounces@xxxxxxxxxxxx
12/09/2009 09:44 AM
Please respond to
Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>


To
"'Web Enabling the AS400 / iSeries'" <web400@xxxxxxxxxxxx>
cc

Subject
[WEB400] Getting XML child Elements PHP






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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.