PHP 4.4.8 kullanarak bu xml ayrıştırmak nasıl?

2 Cevap php

usually i have no problems parsing xml in PHP 5 by using Xml to array class. but now, i have a server with PHP 4.4.8 , and i really don't know how to parse it using built-in functions.

xml böyledir:

<?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>

I echo her arama öğe, başlık ve istiyorum açıklama & url.

Not: Önemli kodu PHP Version 4.4.8 çalışması gerektiğidir

Teşekkürler

2 Cevap

xml_parser* fonksiyonlar hala PHP4'te çalışması gerekir: -

$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);

Derinlik örneklerde daha kılavuzuna göz atın.

Edit: - Burada Bulunan yinelenen: http://stackoverflow.com/questions/132233/what-to-use-for-xml-parsing-reading-in-php4

Ayrıca kullanmak xslt_process ve bir XSLT stil kullanarak süreç olabilir. O sayfadaki bazı örnekler bir göz atın. XSLT'DE aşina değilseniz, here's a simple example sizinkine benzer XML işaretleme ile.