About XML with PHP 
Author Message
 About XML with PHP

Can I search from XML document with PHP searching script. Here is little
example of the XML document:

<?xml version="1.0" standalone="yes"?>
<document>
<aphorism>Shit happens</aphorism>
<author>unknown</author>
<language>English</language>
</document>

So is it possible to search by author and/or aphorism and/or language?



Tue, 26 Apr 2005 02:48:26 GMT  
 About XML with PHP

Quote:

> Can I search from XML document with PHP searching script. Here is little
> example of the XML document:

> <?xml version="1.0" standalone="yes"?>
> <document>
> <aphorism>Shit happens</aphorism>
> <author>unknown</author>
> <language>English</language>
> </document>

> So is it possible to search by author and/or aphorism and/or language?

With recent versions there is some DOM support, for instancen the
following code loads the XML file and searches it for <aphorism>
elements and outputs the node value of the first text child.

<?php
$xmlDocument = domxml_open_file('test20021108.xml') or die("Couldn't
open file.");
$aphorisms = $xmlDocument->get_elements_by_tagname('aphorism');
$aCount = count($aphorisms);
echo "found $aCount aphorism elements<br />\n";
for ($i = 0; $i < $aCount; $i++) {
   $textNode = $aphorisms[$i]->first_child();
   echo "aphorism $i: " . $textNode->node_value() . "<br />\n";

Quote:
}

?>

There is also some XPath support and XSLT support

--

        Martin Honnen
        http://JavaScript.FAQTs.com/



Tue, 26 Apr 2005 20:05:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. XML, HTTP, PHP

2. FW: [PHP Classes] MetaL - a XML based meta-programming language developed using PHP

3. embedding PHP into XML

4. php xml problem

5. XML/PHP

6. Creating XML docs using PHP

7. receiving XML objects in php vi sendAndLoad

8. PHP read/write to an XML file

9. PHP + XML + HTML Entities

10. PHP and XML

11. php & xml

12. xml php

 

 
Powered by phpBB® Forum Software