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:

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.