NYCPHP Meetup

NYPHP.org

[nycphp-talk] libxml in PHP 5

pswebcode, nyc psaw at pswebcode.com
Wed Aug 13 10:17:41 EDT 2003


Looks sleek...  ...but regarding any documentation (full list of functions,
say) for the updated DOM, XSLT and XPATH functionality? 

And if I remember right... SAX, XSLT and DOM XML libs will all be installed
by default on both *nix and Windows?

I have been using DOMXML functions at this time and several web hosts would
not install the library, namely because it is marked as Experimental.

PSaw

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Sterling Hughes
Sent: Wednesday, August 13, 2003 4:17 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] libxml in PHP 5


Am Die, 2003-08-12 um 14.46 schrieb Adam Maccabee Trachtenberg:
> On Mon, 11 Aug 2003, Analysis & Solutions wrote:
> 
> > I was thinking that the new XML parser would necessitate scripts use 
> > different function calls.  Or will the main functions and behavior 
> > remain the same, but only the library be changed?
> 
> The plan is to make the libxml switch seamless and not require any 
> changes in your XML code.

Yes, and kinda.  The SAX extension (ext/xml) will remain the same.

Code that uses the DOM extension will need to be rewritten.  The DOM
extension has always been experimental, and never really worked.  Now it
will, and it will be 100% DOM 2 (and mostly DOM 3) compliant.  The API for
the XSLT extension is also completely changed.

> 
> > If the functions will indeed be different, is there some place to 
> > find docs about these new procedures?  They don't have to be great, 
> > just give me an idea of how to start hacking something simple.
> 
> PHP 5 will also have the SimpleXML extension. I believe the C code in 
> the CVS is also the documentation. (Source code: The ultimate 
> documentation.)

book.xml
<books>
 <book asin="84343483538">
  <title>Winnie the Pooh</title>
  <author>Arthur Milne</author>
  <description>A true classic</description>
 </book>
 <book asin="838488287773">
  <title>The Grapes of Wrath</title>
  <author>John Steinbeck</author>
  <description>Not bad...</description>
  <note>Its wierd, but not many europeans know john steinbeck, they all 
  know arthur milne.</note>
 </book>
</books>

book.php
<?php
$books = simplexml_load_file('book.xml');
foreach ($books->book as $book) {
?>
  <a href="http://www.amazon.com/<?=$book->asin?>"><?=$book->title?></a>
  <br/>
  <?=$book->author?>
  <br/><br/>
  <?=$book->description?>
  <br/>
  <? if (!empty($book->note)) { ?>
    <b>Note:</b> <?=$book->note?>
  <? } ?>
<?php
}
?>

Yep, that's it.  SimpleXML is actually quite powerful.  For example, I wrote
a full WSDL parser using simplexml.  It supports Xpath, Schema and the full
XML infoset.

-Sterling


-- 
"Backups are for wimps. Real men upload their data to an FTP site and have
everyone else mirror it." 
    - Linus Torvalds _______________________________________________
talk mailing list
talk at lists.nyphp.org http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list