jimneely Posted February 5, 2014 Share Posted February 5, 2014 Okay I am new to this so bare with me. I have been trying to suck in a XML file and echo out it's attributes. Here is a example PHP code I am trying to use to do this. I need direction on how to make this work. PLEASE! <?php $xml=simplexml_load_file("Jim.xml"); echo $xml->MachineData->['timeStamp'] . "<br>"; echo $xml->MachineData[0]->['machineID'] . "<br>"; echo $xml->MachineData[0]->['lineID'] . "<br>"; echo $xml->stationName . "<br>"; echo $xml->partNumber . "<br>"; echo $xml->modelNumber . "<br>"; echo $xml->serialNumber . "<br>"; echo $xml->LotNumber . "<br>"; ?> Jim.xml Quote Link to comment Share on other sites More sharing options...
Barand Posted February 5, 2014 Share Posted February 5, 2014 MachineData is your outermost element so $machineData = simplexml_load_file('jim.xml'); echo $machineData['timeStamp'].'<br>'; echo $machineData['machineID'].'<br>'; echo $machineData['lineID'].'<br>'; echo $machineData->TrackingData['stationName'] . '<br>'; // etc Quote Link to comment Share on other sites More sharing options...
boompa Posted February 5, 2014 Share Posted February 5, 2014 How you can figure this stuff out on your own in the future: <?php $xml = simplexml_load_file('Jim.xml'); // Check out the contents print_r($xml); ?> SimpleXMLElement Object ( [@attributes] => Array ( [timeStamp] => 2014-02-04T23:59:52 [machineID] => TM-N158 [lineID] => M200 ) [TrackingData] => SimpleXMLElement Object ( [@attributes] => Array ( [stationName] => HousingHeight [partNumber] => 3051006070 [modelNumber] => [serialNumber] => 14BMJ03570 [LotNumber] => 879066 ) [KanbanNo] => 0 [Data] => SimpleXMLElement Object ( ) ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.