Reply to Re: php and phpxml

Your name:

Reply:


Posted by Jim Michaels on 02/17/06 10:55

"Skeets" <skillet3232@yahoo.com> wrote in message
news:1140028518.474913.47700@z14g2000cwz.googlegroups.com...
> i've spent an hour googling and reviewing documentation for phpxml and
> i'm having trouble implementing phpxml..
>
> i've read
>
> http://www.zvon.org/xxl/XPathTutorial/General/examples.html
>
> and it is pretty straight forward stuff... except there is no
> indication how to actually stick the phpxml code within a php file so
> it is usable.
>
> http://jm3.net/misc/php-xpath-quickstart/
>
> gives examples, but being a noob to this, it isn't too clear to me...
>
> i was able to get this to work:
>
> $x = new XPath( "yourFile.xml" );
> $result = $x->getData("/someElement/elementName");
>
> but i have no clue how to get these to work:
>
> 1. $tree = $x->exportAsXml("/content[1]/blah[1]");
>
> what is content? what is blah? how can i print this content and blah
> as xml?


could be exporting to a specified filepath (but them why didn't it get named
..xml?)
more likely, it could be specifying what part of the document tree to
export. elements are nested you know, just like subdirectories, and like
subdirectories, you can also access then by using html/unix-style filepaths.
just a convenient method of packing a path into a string.

>
> 2. how do i implement the following?
>
> //*[count(BBB)=2]
>
> i tried
>
> $result = $x->getData('//*[count(ip_address)=1]');
> echo $result;
>
> and it kicks out the following error:
>
> XPath error in XPath.class.php:5813 The supplied xPath
> '//*[count(ip_address)=1]' does not *uniquely* describe a node in the
> xml document.Not unique xpath-query, matched 7-times.
>

try putting ip_address in quotes instead. this is bad form. PHP is picking
up the slack by treating it as a string. make it a real string.

> the good news phpxml appears to understand the code (there are 7
> instances of ip_address in the document),

then specify the path to the ip_address you want, like I talked about above.
go thru the elements in the order they are nested by, and that's your path.
and put it in quotes.


> the bad news is that i don't
> ;-)
>
> the functionality that i *really* want, though, is to be able to count
> a given element directly. count() appears to count those elements with
> a certain number of child elements. i want to count the elements
> directly.
>
> can anyone help?

I can't download the library to help you (that page you specified has no
download link). even then I am not that good at looking at other people's
code.

>
> tia...
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация