Using simplexml parsing complex xml
I am using simplexml to extract information from large xml files and store the results in a mysql database. It's all working fine but how do I get at the days in this xml where the days are not attributes or inside tags
<operatingInformation>
<normalOperation>
<operatingDays>
<days&g开发者_StackOverflowt;
<monday />
<tuesday />
</days>
</operatingDays>
</normalOperation>
</operatingInformation>
What I need is to extract the names of the days so I can add them to my database table.
With your XML document parsed as $xml, this will loop over the days and print their names:
foreach ( $xml->normalOperation->operatingDays->days->children() as $dayElem ) {
print $dayElem->getName() ."\n";
}
精彩评论