0
我無法用PHP解析XML中的鏈接。XML解析,從使用PHP的鏈接獲得'rel'值DOMDocument
我知道它一定是簡單的提取,但我找不到任何直接的點文件。
XML
<entry>
<title type="html">Some title</title>
<id>tag:url.com,2012-03-08:/dir/id/11</id>
<link rel="alternate" type="text/html" href="http://someLink.com/?id=11" />
<content type="html">
Some content
</content>
</entry>
的PHP
$contents = $x->getElementsByTagName("content");
$content = $contents->item(0)->nodeValue;
$links= $x->getElementsByTagName("link");
$link = $links->item(0)->nodeValue;
我能得到的內容。例如:
echo $content;
輸出 '某些內容'
但我不能獲取鏈接的rel標籤。
我知道如何用jQuery做到這一點,但我想要一個解決方案,將生成服務器端,所以我可以緩存它更容易。
謝謝
謝謝你,非常非常多。這是直截了當的。 – 2012-04-02 14:33:51