开发者

xml processing using php (simplexml?) [closed]

开发者 https://www.devze.com 2023-02-16 18:00 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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