PHP代码,用于显示RIPE XML文件中的信息
问题描述:
Here is a tool for WHOIS lookups that I use: http://apps.db.ripe.net/search/lookup.html
It can present information in an XML file, like this: http://apps.db.ripe.net/whois/lookup/ripe/inetnum/192.36.171.155.xml
Let's say I wanted to read the XML file by using PHP and present the netname and descr fields in an HTML document, how would I do that?
以下是我使用的WHOIS查找工具: http://apps.db.ripe.net/search/lookup.html p>
它可以 在XML文件中显示信息,如下所示: http:/ /apps.db.ripe.net/whois/lookup/ripe/inetnum/192.36.171.155.xml p>
假设我想使用PHP读取XML文件 在HTML文档中显示 netname strong>和 descr strong>字段,我该怎么做? p> div>
答
Take a look at SimpleXML. Once you've loaded the file it's easy to traverse...
$xml = simplexml_load_file('http://apps.db.ripe.net/whois/lookup/ripe/inetnum/192.36.171.155.xml');
echo $xml->objects->object->attributes->attribute[1]->attributes()->value;