PHP XML Get the “Name” value

jessica14

New Member
How do i read out the "Name" value for the PROP'sI can read the PVAL's using the script below..\[code\]<?xml version='1.0'?><RECORDS><RECORD><PROP NAME="Product"> <PVAL><![CDATA[Produkt1]]></PVAL></PROP><PROP NAME="Value"> <PVAL><![CDATA[10]]></PVAL></PROP><PROP NAME="Status"> <PVAL><![CDATA[Active]]></PVAL></PROP></RECORD><RECORD><PROP NAME="Product"> <PVAL><![CDATA[Produkt2]]></PVAL></PROP><PROP NAME="Value"> <PVAL><![CDATA[20]]></PVAL></PROP><PROP NAME="Status"> <PVAL><![CDATA[Active]]></PVAL></PROP></RECORD><RECORD><PROP NAME="Product"> <PVAL><![CDATA[Produkt3]]></PVAL></PROP><PROP NAME="Value"> <PVAL><![CDATA[30]]></PVAL></PROP><PROP NAME="Status"> <PVAL><![CDATA[Active]]></PVAL></PROP></RECORD>\[/code\]Using the script below i can get the PVAL's.But i would like to get the name values as well, i have tried$strvalue = http://stackoverflow.com/questions/12735104/$node->PROP[6]->NAME; without luck...\[code\]<?php$z = new XMLReader;$z->open('products.xml');$doc = new DOMDocument;// move to the first <product /> nodewhile ($z->read() && $z->name !== 'RECORD');// now that we're at the right depth, hop to the next <product/> until the end of the treewhile ($z->name === 'RECORD'){$node = simplexml_import_dom($doc->importNode($z->expand(), true));$strvalue = http://stackoverflow.com/questions/12735104/$node->PROP[6]->PVAL;echo $strvalue."<p>" ;// go to next <product />$z->next('RECORD');}?>\[/code\]
 
Back
Top