开发者

xml processing using php (simplexml?) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜