[英]How to parse this xml using PHP 4.4.8?
通常我通過使用Xml到數組類來解析PHP 5中的xml是沒有問題的。 但是現在,我有一台使用PHP 4.4.8的服務器,我真的不知道如何使用內置函數來解析它。
xml是這樣的:
<?xml version="1.0" encoding="utf-8" ?>
<?pageview_candidate?>
<SearchResponse Version="2.2">
<web:Web>
<web:Results>
<web:WebResult>
<web:Title>Apple Ipad</web:Title>
<web:Description>The best way to experience the web</web:Description>
<web:Url>http://www.apple.com/ipad/</web:Url>
</web:WebResult>
<web:WebResult>
<web:Title>Apple Tablet Concept: the iPad Touch</web:Title>
<web:Description>This can all be made better!</web:Description>
<web:Url>http://factoryjoe.com/blog/148548/</web:Url>
</web:WebResult>
</web:Results>
</web:Web>
</SearchResponse>
我想echo
每個搜索項目,標題和說明以及網址。
注意:重要的是該代碼應在PHP 4.4.8版本中工作
謝謝
xml_parser *函數仍應在PHP4中工作:
$xml = "...."
$parser = xml_parser_create('UTF-8');
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
查看手冊,以獲取更多深入的示例。
編輯:-在此處找到一個重復項: 在PHP4中用於XML解析/讀取的內容
您還可以使用xslt_process並使用XSLT樣式表對其進行處理。 看一下該頁面上的一些示例。 如果您不熟悉XSLT, 這是一個簡單的示例,它具有與您相似的XML標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.