phpxpath-users Mailing List for Php.XPath (Page 10)
Brought to you by:
bs_php,
nigelswinson
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(346) |
Nov
(8) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(30) |
Feb
(13) |
Mar
|
Apr
(3) |
May
(70) |
Jun
(26) |
Jul
(48) |
Aug
(22) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
|
2003 |
Jan
(3) |
Feb
(3) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2004 |
Jan
(4) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(12) |
Aug
(8) |
Sep
(2) |
Oct
(2) |
Nov
(3) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2006 |
Jan
(3) |
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Nigel S. <nig...@us...> - 2002-05-14 18:51:03
|
> > Ok the default order for the results is now doc order. Sorting by other > > means probably isn't too difficult anyway, as you can use the usort() > > function that takes a callback of two elements that you can then write your > > own function to compare elements with. > > wouldn't disagree with you Nigel, but the problem is surely where there is no > element to sort by. If you have in your xml source > <a><b><c><a><b><c><b><a> > and you say match("//a | //b"), it should return a b a b b a, but it doesn't; > it returns the <a>s first, then the <b>s, i.e. a a a b b b. This is wrong, as > you are losing information, namely the document order. Of course, as you say, > if you want it sorted in some particular sequence, then you can do so using > PHP functions. Yeah it used to return aaabbb, but as I said "the default order for the results is now doc order". So as of CVS file version 1.86, the order returned will be ababba. If you want to sort by some other criteria, other than doc order, then you can use usort(). Hopefully that meets the needs... Nigel |
From: Sam B. <bs...@us...> - 2002-05-14 16:03:50
|
Hi Jan, It's not a bug. appendChild() and replaceData() need a valid XML string as second parameter: E.g. $xpath->appendChild("/root[1]","<TEST/>"); The main advantage (and reason) is that it's now possable to append any valid XML (not just a single child) to the doc. E.g. $xPath->appendChild("/root[1]"', '<CC> bla bla <DD dd="d"> foo</DD> <EE/> </CC>'); The return value of appendChild() and replaceData() are currently bool. But it would make sens if they would return the abs. Xpath string of the inserted node. (Something to do). -- Sam Blum <bs...@us...> =========================== For the most recent version of PHP.XPath and an archive of this list visit: http://sourceforge.net/projects/phpxpath |
From: J. C. <jan...@im...> - 2002-05-14 12:52:34
|
Hello, I would like to use the new Version but I got problems when changing something. Here is a simple example: ====================================================== <? require_once("XPath.class.php"); //new //require_once("XPath.class_V2.php"); //old $xmlfile="xmlfile.xml"; echo "[new XPath]<BR>"; $xpath = new XPATH($xmlfile); echo "[appenChild \"TEST\" to \"root[1]\"]<BR>"; $child=$xpath->appendChild("/root[1]","TEST"); echo "[replaceData \"TEST\"]<BR>"; $xpath->replaceData($child,"TEST"); echo "[exportToFile] <BR>"; $xpath->exportToFile($xmlfile,'','<?xml version="1.0" encoding="iso-8859-1" standalone="yes"'.'?'.'>'); ?> ====================================================== This code gives me this output: ====================================================== [new XPath] [appenChild "TEST" to "root[1]"] XPath error in XPath.class.php:4524 XPath error in XPath.class.php:1454. Message: In importFromString(): XML error in given string on line 1 column 0. Reason:syntax error [replaceData "TEST"] [exportToFile] PHP Warning: Undefined variable: PHP_SELF in C:\Server-Entwicklung-V2\imeso\web\Administration\data\XPath.class.php on line 4698 ====================================================== The XML Code is: ====================================================== <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?><root> </root> ====================================================== When I use the old version it works nice so I think it might be a bug. Any help? (The warning is no problem - I normally comment that section at line 4698) Cheers Jan |
From: Peter R. <php...@pe...> - 2002-05-14 10:29:07
|
> > Imagine you want to build a table-of-contents for an XHTML page. > > The most reasonable expression to me seems to be: > > //h1 | //h2 | //h3 | //h4 | //h5 | //h6 > > and then process this e.g. building a nested list. can you not use starts-with("h") function to return them all in one node-set? |
From: Peter R. <php...@pe...> - 2002-05-14 10:29:04
|
On Monday 13 May 2002 21:48, Nigel Swinson wrote: > > Ok the default order for the results is now doc order. Sorting by other > means probably isn't too difficult anyway, as you can use the usort() > function that takes a callback of two elements that you can then write your > own function to compare elements with. wouldn't disagree with you Nigel, but the problem is surely where there is no element to sort by. If you have in your xml source <a><b><c><a><b><c><b><a> and you say match("//a | //b"), it should return a b a b b a, but it doesn't; it returns the <a>s first, then the <b>s, i.e. a a a b b b. This is wrong, as you are losing information, namely the document order. Of course, as you say, if you want it sorted in some particular sequence, then you can do so using PHP functions. This is similar to the problem we had with the original phpxml retrieving parts of text nodes in the wrong order: once the program has sorted it like this, there is no criteria by which you can get it back to the original sequence. |
From: Nigel S. <nig...@us...> - 2002-05-13 20:47:10
|
> What I'll try to do is to make doc order the default output, but there may > still be occasions where sorting the data by some other criteria is useful. Ok the default order for the results is now doc order. Sorting by other means probably isn't too difficult anyway, as you can use the usort() function that takes a callback of two elements that you can then write your own function to compare elements with. So you would do something like this (haven't tested this...): $XPathObj = new XPath; function cmp($a, $b) { global $XPathObj; $sA = $XPathObj->getData($a.'/SomewhereElse'); $sB = $XPathObj->getData($b.'/SomewhereElse'); return (strcmp($sA, $sB)); } $aPaths = $XPathObj->evaluate('something or other'); usort($aPaths, "cmp"); Nigel |
From: Philipp L. <le...@hi...> - 2002-05-13 19:15:03
|
From: "Nigel Swinson" <nig...@us...> >.. > What I'll try to do is to make doc order the default output, but there may > still be occasions where sorting the data by some other criteria is useful. >.. Oh, that's definitely totally useful to have that as an option. In fact, I spend hours biting my knee because the MSXML won't let me produce any kind of sorted output. In XSLT this seems to come naturally. |
From: Nigel S. <nig...@us...> - 2002-05-13 18:15:38
|
> From: "Nigel Swinson" <nig...@us...> > > Let me know if that other getData() fix doesn't solve your problem. Send > > some examples and stuff and I'll try to locate the bug you are getting. > > Think it's likely that it is your bug though. > > > > Might be it's my bug, but the 2.2 version works good. Well I attach the > forum. It's tested on Win 98 PWS with the results described below. > What you should do is run the index.php. Now click on "current threads" of > the top most category. > The result is many threads, and I echo the XPath: > XPath: "posts/post[@replyTo = '0']" result-count: 7 > > This was version 2.2. > Now go rename "XPath.class.php" to "old_XPath.class.php" and rename > "new_XPath.class.php" to "XPath.class.php" (which is from the latest release > you mentioned in the list). Suddenly no more posts are shown, as the result > on "current threads" is: > XPath: "posts/post[@replyTo = '0']" result-count: 0 > > (Please note that there's a single function "getAttribute" that I added to > both the old and new class. It's not accessed in this part of the problem, > but you can find it searching for "Phil".) Ok I just loaded your forum, and you aren't using the latest version from CVS. I did a diff between your version of Php.XPath and the latest and there were several bug fixes that were in mine but not in yours, but add to that you had your getAttribute function. When I made it use the latest version by adding your getAttribute function it all worked fine :o) So if you visit http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpxpath/ and navigate your way to the development version, you can get the fix without waiting for 3.1 Cheers, Nigel |
From: Nigel S. <nig...@us...> - 2002-05-13 18:07:48
|
> > How do you sort that, other than in document order? > > And if you add a further nnn <p> nodes - the norm in document files - how > can > > they be used if not in document order? In what order can the 'nodes' of, > say, > > a Shakespeare play be processed other than the one he wrote?! > >.. > > Yes. And also I could imagine a dozen other cases, except my current one > where I'd need it. > Imagine you want to build a table-of-contents for an XHTML page. > The most reasonable expression to me seems to be: > //h1 | //h2 | //h3 | //h4 | //h5 | //h6 > and then process this e.g. building a nested list. > It's very important here that an h2 following an h1 in the original document > can be understood as belonging to this h1 as a sub-heading. > (I do the above in an MSXML4-based Content Management System.) Ok I totally agree that doc order is the most useful, but how about this scenario: <?xml version="1.0" ?> <XmlDatabase> <Sermons> <Sermon RecordId="1"> <Date>1-Jan-92</Date> <CatalogueNo>BRJ 01</CatalogueNo> <Speaker>Brian Russell-Jones</Speaker> </Sermon> <Sermon RecordId="3"> <Date>1-Jan-92</Date> <CatalogueNo>WS 01</CatalogueNo> <Speaker>Wayne Sutton</Speaker> </Sermon> <Sermon RecordId="4"> <Date>1-Mar-92</Date> <CatalogueNo>BRJ 04</CatalogueNo> <Speaker>Brian Russell-Jones</Speaker> </Sermon> <Sermon RecordId="5"> <Date>1-Apr-92</Date> <CatalogueNo>WS 02</CatalogueNo> <Speaker>Wayne Sutton</Speaker> </Sermon> </Sermons> </XmlDatabase> You want to search for all the sermons, but have them sorted by date, catalogue, or speaker. If sorted by date you get: /XmlDatabase[1]/Sermon[1] /XmlDatabase[1]/Sermon[2] /XmlDatabase[1]/Sermon[3] /XmlDatabase[1]/Sermon[4] If sorted by speaker you get: /XmlDatabase[1]/Sermon[1] /XmlDatabase[1]/Sermon[3] /XmlDatabase[1]/Sermon[2] /XmlDatabase[1]/Sermon[4] etc. What I'll try to do is to make doc order the default output, but there may still be occasions where sorting the data by some other criteria is useful. Nigel |
From: Nigel S. <nig...@us...> - 2002-05-13 10:10:03
|
> > The documentation is all automatically built from the php source file using > > a perl script. > > just out of curiosity - why did you write this in Perl rather than php? a) I'd learnt Perl before PHP and was therefore more fluent in Perl. b) I already had a "framework" for building scripts like this. ie analyse a file and produce an XML file. c) I've always thought of PHP as a server side pre-processor rather than a language for building utility scripts in. The output of php is naturally html, which isn't ideal if you want to drive it from a batch file. With perl your output can be whatever you want it to be. Were I to build the doc generator again from scratch then I don't know whether I would have chosen PHP or Perl. The a and b reasons above were 90% of the reason it was Perl rather than PHP. :o) Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: Philipp L. <le...@hi...> - 2002-05-12 13:11:05
|
From: "Peter Robins" <php...@pe...> >.. > How do you sort that, other than in document order? > And if you add a further nnn <p> nodes - the norm in document files - how can > they be used if not in document order? In what order can the 'nodes' of, say, > a Shakespeare play be processed other than the one he wrote?! >.. Yes. And also I could imagine a dozen other cases, except my current one where I'd need it. Imagine you want to build a table-of-contents for an XHTML page. The most reasonable expression to me seems to be: //h1 | //h2 | //h3 | //h4 | //h5 | //h6 and then process this e.g. building a nested list. It's very important here that an h2 following an h1 in the original document can be understood as belonging to this h1 as a sub-heading. (I do the above in an MSXML4-based Content Management System.) |
From: Peter R. <php...@pe...> - 2002-05-12 12:36:37
|
On Thursday 09 May 2002 23:37, Nigel Swinson wrote: > > > > BTW is it normal that e.g. > > "myElement | myOtherElement" > > (or maybe ".//myElement | .//myOtherElement") > > will return the elements not in the order they appear in the XML, but in the > > order as listed in the XPath-string? > > > I wish they could be listed as appearing in the XML, as this is the > > result > I > > get from MSXML. Is it not standardized, and up to the XPath-parser to > decide > > the returned order, or simply a PHPXPath bug? > > Could be. Looking at the XPath spec it says > > ========================== > The primary syntactic construct in XPath is the expression. An expression > matches the production Expr. An expression is evaluated to yield an object, > which has one of the following four basic types: > a.. node-set (an ***unordered*** collection of nodes without duplicates) > b.. boolean (true or false) > c.. number (a floating-point number) > d.. string (a sequence of UCS characters) > ========================== > > So we don't have to guarentee anything at all about the order. > > If you could locate something for us that says that the way we do it is > wrong then we can happily change it. I agree with you that it is probably > more useful to be in the doc order. hmm, this bit of the xpath spec seems very dubious to me. The data model section of XPath spec goes on at length about document order, and many functions such as preceding, following, first, last etc depend on nodes being in that order. If the Xpath xpression (evaluate in phpxpath terms) doesn't return nodes (i.e. set up the array) in that sequence, how can we use it? The particular case Philipp raises where you have a union is perhaps a special case, as it depends on whether you define 'union' as one result-set followed by another (what it seems phpxpath currently does) or merged into one (as I too think it should do). > Perhaps what we should do is to have a sort function. It takes a function > (An XPath expression?) that will determine which of two nodes are "greater" > and bubble sorts the list? ok if you have a structured-data type of xml file, but if you have a text-document type of node, such as <p>Here are a few examples: <li>first example</li> <li>example no 2</li> <li>a further example</li> and so on</p> How do you sort that, other than in document order? And if you add a further nnn <p> nodes - the norm in document files - how can they be used if not in document order? In what order can the 'nodes' of, say, a Shakespeare play be processed other than the one he wrote?! |
From: Peter R. <php...@pe...> - 2002-05-12 12:30:51
|
On Sunday 12 May 2002 2:16, Nigel Swinson wrote: > > The documentation is all automatically built from the php source file using > a perl script. just out of curiosity - why did you write this in Perl rather than php? |
From: Nigel S. <nig...@us...> - 2002-05-12 01:27:14
|
> downloaded the cvs version, but it looks like getData will no longer fetch > attributes, either in the @ or the attribute:: notation. I have changed my > scripts to use getAttributes instead, but is this deliberate or a bug? > > When I ran my old scripts - using getData - it produced errors for the > implode line immediately following. Shouldn't === read == ? The errors went > away when I changed this! Not deliberate, so I suppose you could class it as a "bug", I prefer the term "ommision" :o) Anyway I've coded this in now, so getData() can be used to get the data of an attribute, however getAttributes() is faster, and I would recommend it if you know that you are getting from an attribute and not a node. I've added a test to the test harness so that future releases don't suffer from this numpty attack. The change is in CVS if you can't wait for it to be released. Will probably wait several more weeks before 3.1 Please keep a close eye out for similar bugs relating to attributes. The test harness that we've built uses DOM test data (the DOM-TS project from w3c). In the DOM world, attributes are quite different entities to Nodes, so the coverage in the Php.XPath functions where attributes and nodes are considered the same kind of entities is poor. Cheers, Nigel |
From: Nigel S. <nig...@us...> - 2002-05-12 01:27:11
|
> Much improved - many thanks. A couple of small points: > > 1. the sample code at the end of the php file does not appear in the html (or > xml) documentation, so the usage text isn't correct :-) The documentation is all automatically built from the php source file using a perl script. The sample usage appears at the end of the php file, but not the xml/html file, and the perl script doesn't parse out the example test script. I've altered the comment in the php file to help to indicate that the usage is not in the .html file. I want the GeneratePhpDocumentation.pl script to be as generic as possible, so I am very reluctant to alter it to pick out the sample usage as well to put in the .html doc. > 2. the internal links in the html file have never worked and I've just > investigated why. The # should be removed from all the names in the anchors - > <a name="function"> not <a name="#function"> Fixing this (looks like this is > in the xslt script) would make the html documentation much easier to use > :-) Ah thanks. IE wasn't bothered by this, so I hadn't noticed. Have updated the XSL. Nigel |
From: Nigel S. <nig...@us...> - 2002-05-12 01:27:08
|
> Just looked at the code for this function, and it looks like the > documentation does not match the function. According to the doc, the default > is 0/off; but the default in the function definition is 1, and it will output > errors if not called. So to turn off error reporting, it looks like you have > to call setVerbose(0). Well spotted. The comment was pretty badly written and wrong. Has now been updated. The default for the class is level 1. The default for the function is 1. So indeed to turn off error reporting you need to go setVerbose(0). If these defaults are a very annoying problem then we can change them :o) Nigel |
From: Peter R. <php...@pe...> - 2002-05-10 18:20:59
|
Just looked at the code for this function, and it looks like the documentation does not match the function. According to the doc, the default is 0/off; but the default in the function definition is 1, and it will output errors if not called. So to turn off error reporting, it looks like you have to call setVerbose(0). |
From: Philipp L. <le...@hi...> - 2002-05-10 17:54:34
|
From: "Nigel Swinson" <nig...@us...> > > Well done! You've found the first 3.0 bug. If you get the latest version > out of cvs then it should work. Have added a set of tests to the test > harnes so that this bug won't appear in future releases. > Sorry, still doesn't work... I use a whole lot of getData, is it causing trouble? (I read something from Peter Robins along the lines.) |
From: Peter R. <php...@pe...> - 2002-05-10 12:29:47
|
Much improved - many thanks. A couple of small points: 1. the sample code at the end of the php file does not appear in the html (or xml) documentation, so the usage text isn't correct :-) 2. the internal links in the html file have never worked and I've just investigated why. The # should be removed from all the names in the anchors - <a name="function"> not <a name="#function"> Fixing this (looks like this is in the xslt script) would make the html documentation much easier to use :-) |
From: Peter R. <php...@pe...> - 2002-05-10 11:21:14
|
On Friday 10 May 2002 1:00, Nigel Swinson wrote: > Well done! You've found the first 3.0 bug. If you get the latest version > out of cvs then it should work. Have added a set of tests to the test > harnes so that this bug won't appear in future releases. downloaded the cvs version, but it looks like getData will no longer fetch attributes, either in the @ or the attribute:: notation. I have changed my scripts to use getAttributes instead, but is this deliberate or a bug? When I ran my old scripts - using getData - it produced errors for the implode line immediately following. Shouldn't === read == ? The errors went away when I changed this! |
From: Peter R. <php...@pe...> - 2002-05-10 09:52:57
|
On Friday 10 May 2002 1:11, Nigel Swinson wrote: > DTDs aren't parsed. Have observed that this is a deficiency, wasn't sure > how important it was to our users. Not sure how complex it would be to > parse and use either. > > Comments? it's a nice idea to be able to get default values out of a dtd, but surely the way to go to do this is to use xsd and not dtd. Then we can use phpxpath as it stands to get the appropriate default out of the xsd; phpxpath itself would not need to be changed - I can imagine the changes needed to use dtds would be substantial. |
From: Philipp L. <le...@hi...> - 2002-05-10 00:29:26
|
From: "Nigel Swinson" <nig...@us...> > > DTDs aren't parsed. Have observed that this is a deficiency, wasn't sure > how important it was to our users. Not sure how complex it would be to > parse and use either. > > Comments? > It's nothing critical for me. Of course I validate my XML but usually just in developing the application, writing test data manually and programmatically, and then I have other tools available. I think the top priority is speed (I didn't check out the new debugged 3.0 version yet -- as I mentioned, the older 3.0 failed with my PHP forum -- but I was really happy to hear it's apparently so much faster). Of course it's a tiny problem that e.g. DTD default attribute values (if the attribute is omitted in the XML) aren't understood, because this means I have to replicate those values in the PHP in some way. >.. > I think that the Php.XPath class should stick to returning an unset value if > the attribute is not set. It probably makes for a more useful function. No, somehow I remember it returning an *error* (script ended) when the attribute didn't exist (version 2.2) -- I didn't even get the chance to assign the return value to a variable to check it for being empty/ set (I test on Windows PHP/ PWS). |
From: Nigel S. <nig...@us...> - 2002-05-10 00:10:08
|
Don't seem to have a record of replying to this... > I put my little own getAttribute() function in the class. Did I miss > something or is there really only getAttributes(), and if there's no > attribute of that kind available it causes an error? That were my experience > with v2.20. Well I use a DTD to my XML that even expands some attributes to > a value if none is given but I guess DTDs aren't parsed. Version 3 only has a getAttributes() function, but it has an optional parameter that turns it into a getAttribute() function. DTDs aren't parsed. Have observed that this is a deficiency, wasn't sure how important it was to our users. Not sure how complex it would be to parse and use either. Comments? > Another question, how can/ should I comment the class now that I did a > little change? I tried to scan the mozilla license for some information. I > hope it's not illegal to redistribute the class inside my package (it's not > the core, I just use it for the free QML-interpreter at > http://questml.com ). Comment it? Well in the JavaDoc style: http://java.sun.com/j2se/javadoc/writingdoccomments/index.html and you should label yourself as the author using the @author tag. > My own function actually returns not null but an empty string if the > attribute is not found, which I think is not really standard but very nice > for my own purpoes. Now in case it's not a workaround for something that's > already in the class here goes my source (just as reference with no intend > to have it in any "official" version). > > function getAttribute($absoluteXPath, $attributeName) > { > $attributeValue = ""; > $attributes = $this->getAttributes($absoluteXPath); > foreach ($attributes as $key => $value) > { > if ($key == $attributeName && $attributeValue == "") > $attributeValue = $value; > } > > return $attributeValue; > } I think that the Php.XPath class should stick to returning an unset value if the attribute is not set. It probably makes for a more useful function. You can use the empty() and isset() functions to determine the state of the return value, but I agree that it might be a little annoying to use. What you could do is create a Php.XPath "wrapper" and overwrite the supplied getAttributes() function that handles errors and nulls in the way you want it too. I think that would be the best idea. ie. class MyXPath extends XPath { // My overridden version of getAttributes. Means return value is "" instead of null. function getAttributes($absoluteXPath, $attrName=NULL) { $ret = parent::getAttributes($absoluteXPath, $attrName); if (!$ret) return ""; return $ret; } } Cheers Nigel |
From: Nigel S. <nig...@us...> - 2002-05-09 23:58:54
|
> I successfully downloaded the new version and replaced version 2.2. > However, my forum now doesn't work anymore. It doesn't cause an error, it > just returns an array of count 0. > > This is my XPathQuery, which I pass to ->match ... > > posts/post[@replyTo = '0'] > > on the document-root of data like this, submitted via ->importFromString: > > <?xml version="1.0"?> > <posts> > > <!-- "about" section --> > > <post id="43" replyTo="0"> > <title>Question</title> > <author>xyz</author> > <text>....</text> > </post> > > <post id="45" replyTo="43"> > <title>Re: Question</title> > <author>abc</author> > <text>....</text> > </post> > > <!-- ... many more posts --> > > </posts> > > The forum overview does still work the same (it checks for the latest post > and latest author). > Am I doing something wrong or is this a bug in the 3.0 beta version? Well done! You've found the first 3.0 bug. If you get the latest version out of cvs then it should work. Have added a set of tests to the test harnes so that this bug won't appear in future releases. Cheers, Nigel |
From: Nigel S. <nig...@us...> - 2002-05-09 22:36:07
|
> This is great news. I will replace it on the systems I use it at (namely at > http://questml.com and http://outer-court.com/tech/forum.htm ) and of course > do some Beta testing. > > BTW is it normal that e.g. > "myElement | myOtherElement" > (or maybe ".//myElement | .//myOtherElement") > will return the elements not in the order they appear in the XML, but in the > order as listed in the XPath-string? Hmmm, I'm not sure. > I wish they could be listed as appearing in the XML, as this is the result I > get from MSXML. Is it not standardized, and up to the XPath-parser to decide > the returned order, or simply a PHPXPath bug? Could be. Looking at the XPath spec it says ========================== The primary syntactic construct in XPath is the expression. An expression matches the production Expr. An expression is evaluated to yield an object, which has one of the following four basic types: a.. node-set (an ***unordered*** collection of nodes without duplicates) b.. boolean (true or false) c.. number (a floating-point number) d.. string (a sequence of UCS characters) ========================== So we don't have to guarentee anything at all about the order. If you could locate something for us that says that the way we do it is wrong then we can happily change it. I agree with you that it is probably more useful to be in the doc order. Perhaps what we should do is to have a sort function. It takes a function (An XPath expression?) that will determine which of two nodes are "greater" and bubble sorts the list? Nigel |