xml processing using php (simplexml?) [closed]
How to access certain child's values? Let's say we have an XML:
http://www.more2home.dk/pi/Hvilestol_Model_090_m_skammel_l%E6der_5854_70.aspx?xml=1
How to acces e.g. ImageUrl (<ImageUrl></ImageUrl>)
and extract http://www.more2home.dk/SL/PI/290/9/a132edf开发者_如何学运维b-16e7-47b3-b781-8c0a973cc46b.jpg?c=0_1
$sxml = new SimpleXMLElement('http://www.more2home.dk/pi/Hvilestol_Model_090_m_skammel_l%E6der_5854_70.aspx?xml=1', 0, true);
echo (string) $sxml->export->exportdata->Product->ImageUrl;
try something like
$s = simplexml_load_file('http://www.more2home.dk/pi/Hvilestol_Model_090_m_skammel_l%E6der_5854_70.aspx?xml=1');
echo $s->xml->export->exportdata->Product->ImageUrl;
or very simple with xpath:
$result = $s->xpath('//Product/ImageUrl');
if ($result) {
foreach($result as $node) {
echo $node;
}
}
精彩评论