i have this xml file
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
</CATALOG>
with my php code i am able to get the parent node <CATALOG> then all the other data such as <TITLE> etc etc , how would i go about getting the <CD> tag?? Here is the php code
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
//recieves filename from client
$xml_filename = './xml/'.$_REQUEST['fileName'];
//loads xml file
$xmlobjects = simplexml_load_file($xml_filename,"SimpleXMLElement", LIBXML_NOERROR);
//check for valid xml file, '===' compares type
if ($xmlobjects === FALSE)
{
$jsonString = '{ "error" : "The XML file that has been selected is invalid, please select another." }';
echo $jsonString;
} else {
//first xml tag
$rootnode = $xmlobjects->getName();
//Parent Node Name
$parentNode = $rootnode;
//number of nodes within xml document
$childrenNodes = $xmlobjects->children();
//attributes within node
$firstchild = $childrenNodes[0];
$jsonString = '{ "parentNode" : [';
$jsonString = $jsonString.'"'.$parentNode.'" ,';
$jsonString = substr_replace($jsonString ,"",-1);
//names of the attributes within the child node (table headings)
$jsonString = $jsonString.'], "childNodeHeadings" : [';
foreach ( $firstchild as $element )
{
$jsonString = $jsonString.'"'.$element->getName().'" ,';
}
//remove extra ","
$jsonString = substr_replace($jsonString ,"",-1);
//start new variable
$jsonString = $jsonString.'], "childData" : [';
//all elements values into a JSON array
foreach ( $childrenNodes as $child )
{
$jsonString = $jsonString.'[';
foreach ( $child as $element => $value )
{
$jsonString = $jsonString.'"'.$value.'",';
}
$jsonString = substr_replace($jsonString ,"",-1);
$jsonString = $jsonString.'],';
}
//remove extra ","
$jsonString = substr_replace($jsonString ,"",-1);
//end array and JSON string
$jsonString = $jsonString.']}';
//output JSON stirng
echo $jsonString;
}
?>
bare in mind i am opening multiple xml files so each node has different titles , so i could be opening up a film xml doc so <CD> would now be <FILM>.