phpxpath-users Mailing List for Php.XPath (Page 16)
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: <nig...@us...> - 2001-10-09 13:11:33
|
Phpxml was written on a system that didn't care if an array index wasn't = set yet. The windows PHP engine isn't one of these so you need loads of = if (!isset(arrayentry)) {arrayentry =3D ""} bits throughout your code. I've attached Tim Strehle's patch for this bug. I haven't tried it = myself, but it was the first one that came to hand. Contrary to the other posting by yf32, I would recommend you use = require_once() as xml.php doesn't change, and contains only definitions. Nigel (What do you know, we made it more than 24 hours without a posting to = this list :o) ----- Original Message -----=20 From: <pie...@si...> To: <us...@li...> Sent: Wednesday, July 11, 2001 4:37 PM Subject: [phpXML] beginners question >=20 > I tried to use the phpxml package (latest version on = http://www.phpxml.org/) > but i encountered errors when running the included example files. > Even a very simple test i made generated an error : >=20 > <? > require getenv('DOCUMENT_ROOT') . '/../common/xml.php'; > $doc =3D new XML('base.xml'); > echo $doc->get_file(); > ?> >=20 > The base.xml document contains only this : > <?xml version=3D"1.0" encoding=3D"iso-8859-1"?> > <test> > </test> >=20 > I expected this to just display this simple XML document, but instead = it > generated errors : > <br> > <b>Warning</b>: Undefined index: /test in = <b>/www/wine/common/xml.php</b> > on line <b>443</b><br> > <br> > <b>Warning</b>: Undefined index: in <b>/www/wine/common/xml.php</b> = on > line <b>456</b><br> > <br> > <b>Warning</b>: Undefined index: in <b>/www/wine/common/xml.php</b> = on > line <b>464</b><br> > <test/> >=20 > All examples in the package (governement, xpath) generated simular = problems. > What am i doing wrong ?.. >=20 > Pieter Bosteels > i-Merge >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 |
From: <nig...@us...> - 2001-10-09 13:11:28
|
Did you try $BasePrice =3D $xml->get_content($Product."/Pricing[1]/BasePrice[1]"); ? All paths to get_content must be complete. You seem to have missed the = [1] in the pricing argument. Nigel ----- Original Message -----=20 From: <sh...@co...> To: <us...@li...> Sent: Monday, July 09, 2001 3:50 PM Subject: [phpXML] RE: [phpXML] Subscription successful > Hello.....please forgive my question if it is > stupid, I am a newbie to XML. Can anyone assist. > Feel free to email me directly at sh...@co... >=20 >=20 >=20 > I am trying to parse the following XML file >=20 > http://www.coolshopping.com/xml/derek.xml >=20 > with the following script: >=20 > <?php >=20 > // Include the <phpXML/> class. > include("xml.php"); >=20 > // Create an XML object for the XML file. > $xml =3D new XML("derek.xml"); >=20 > // Check whether a search term was given. > $Products =3D $xml->evaluate("//Product"); >=20 > // Run through all members of the government. > foreach ( $Products as $Product ) > { > // Retrieve information about the person. > $Code =3D $xml->get_content($Product."/Code[1]"); > $Description =3D > $xml->get_content($Product."/Description[1]"); > $Url =3D $xml->get_content($Product."/Url[1]"); > $Caption =3D = $xml->get_content($Product."/Caption[1]"); > $Thumb =3D $xml->get_content($Product."/Thumb[1]"); > $BasePrice =3D $xml->get_content($Product."/Pricing/BasePrice[1]"); >=20 > // Display the information. >=20 >=20 > echo "merchant name: to be obtained <br>\n"; > echo "product sku: $Code <br>\n"; > echo "product name: $Description <br>\n"; > echo "product category : ?????<br>\n"; > echo "product short desc: $Caption <br>\n"; > echo "product price: $BasePrice <br>\n"; > echo "product manuf: ???? <br>\n"; > echo "product img url: $Thumb<br>\n"; > echo "product click url: $Url <br><hr>\n"; >=20 >=20 >=20 > } >=20 > ?> >=20 >=20 > I do not understand how to obtain the fields: >=20 > BasePrice > ProductRef Url >=20 > You can see my results at >=20 > http://www.coolshopping.com/xml/test.php3 >=20 > Can you give me some instructions on how to obtain these sub-level > fields? >=20 > Thank you in advance!! >=20 >=20 >=20 >=20 > Amy Strycula, Creative Director > Coolshopping.com > http://www.coolshopping.com > http://www.coolshopping.tv > (412) 366-7545 voice > (412) 366-8528 fax >=20 >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:11:23
|
Have you tried: $aArray =3D = $calendarXML->evalute("/calendar[1]/month[normalize-space(@number)=3D'01'= ]/day[normalize-space(@number)=3D'02']","entry"); // ...You should really check that $aArray has exactly 1 element, = then.... $newNode =3D $calendarXML->add_node($aArray[0],"entry"); $calendarXML->add_content($newNode,"something"); Undoubtedly addnode will require an ABSOLUTE address of the node to = which you would like to add a node to. If you pass evalute the string = of the search that you think will produce you 1 node, then evaluate will = return you an array of absolute addresses. You can then pick the first = address and add a node there. get_content, set_content, get_attributes, set_attributes, add_node, = delete_node ALL require ABSOLUTE FULLY QUALIFIED ADDRESSES. ie = /a[1]/b[2]/c[3] If you want to use fancy XPath you have to use evalute() to obtain the = absolute address then pass that back into the other "lower level" = functions. There have been loads of postings along these lines so far, and a lot of = people on this list who still haven't quite got this point yet (It took = me a while too...). If you are ever having difficulty, then call = evalute() and print_r() the results. This will tell you if you XPath is = wrong. The documentation that declares that functions like add_node or = get_content take XPath expressions is somewhat misleading in that you = can't pass in any old XPath expression. You must pass in a subset of = XPath mainly those XPath expressions that are fully qualified. :o) Nigel ----- Original Message -----=20 From: <ga...@wh...> To: <us...@li...> Sent: Monday, July 09, 2001 5:45 PM Subject: [phpXML] Problems using element[@attribute=3D''] syntax ?? > Hi, >=20 > I can't, for the life of me, get the following working: >=20 > $newNode =3D > = $calendarXML->add_node("/calendar[1]/month[normalize-space(@number)=3D'01= ']/da > y[normalize-space(@number)=3D'02']","entry"); > $calendarXML->add_content($newNode,"something"); >=20 > I've checked my syntax and it appears to be fine but no matter what I = do it > won't add the node in. Does anybody have any ideas? I was hoping to = use this > method to help me to handle a calendar system quicker. >=20 > Regards, >=20 > Gareth >=20 >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:11:18
|
I looked into this the other day and I think it will require a fairly = major rewrite of some of the code. Currently the internal structure = only has one text parameter per node, so when it reads "Text" it adds it = to the text node of blah1, then when it reads "text" then it appends it = to the text node to get "Text text". Hence when you write it back out = the internal structure has lost the descriptive ability to Put "Text" = before <blah2> and "text" after </blah2>. In order for phpXML to support this kind of behaviour, the internal = data-structure needs to be able to associate a text block that comes = after a element. You could then assoicate "text" as the after element = text of the <blah2> tag. So in this example <blah> has text data of "Text", and <blah2> has text = data of "more" and a post-element-text-data of "text". Clearly the root = element is not allowed to have any post-element-text-data as I think = this would be invalid XML.=20 At least that's how I thought I'd do it... Fortunately I don't need = this feature for my application. So unless I get really bored I won't = be implementing this :o) Try calling print_r() on the object after you have given it an xml file = and you'll quickly see the internal structure. Incidentally, I've written a get_file_as_xml() function that dumps the = object in a format suitable for writing straight to file. When I've = finished testing I'll pass it on to you all. Nigel ----- Original Message -----=20 From: <rot...@ne...> To: <us...@li...> Sent: Wednesday, July 04, 2001 8:12 AM Subject: [phpXML] miss-match > How can I get around phpXML's tendency to place tags inside regular = text > after the tag containing the text. > i.e., > <blah1> > Text<blah2>more</blah2>text. > </blah> > Comes out >=20 > Text text.more >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:11:14
|
> -When I call $xmlobj->get_file(); it will go through the = $xmlobj->nodes > array and format the XML document. > -For every 'text' node it will scan for characters such as "<>&". > -If it encounters such characters it will add the <![CDATA[ tag before > and ]] tag after the 'text' node. > -Else just write out the 'text' node. >=20 >=20 > if (strspn($this->nodes[$root]["text"], "<>&") > 0) { > // Add the character data to the XML data with CDATA tags around it. > $xml .=3D $before." <![CDATA[\n"; > $xml .=3D $before." ".$this->nodes[$root]["text"]."\n"; > $xml .=3D $before." ]]>\n"; > } else { > // Add the character data to the XML data. > $xml .=3D $before." ".$this->nodes[$root]["text"]."\n"; > } I'm not sure that this actually solves the stated problem though as I = think I am right in saying that this is a fix that goes into get_file(). = Therefore if the datastructure can't describe = "Before<tag>Middle</tag>End", then it's not going to be able to print = it. This fix will cope with usage of the object that make calls to = set_content("address","Some text <B>that</B> contains some markup."). = But if the xml file that you read in already has "Some text <B>that</B> = contains some markup." then the class is going to loose this structure = in the parse. Basically phpxml's internal datastructure is lossy. You can't read to = object and write back out to file and have two logically identical = files. Ideally it ought to be. We need a more complete fix for this in the constructor or = load_from_file function I think.... Nigel > How can I get around phpXML's tendency to place tags inside regular = text > after the tag containing the text. > i.e., > <blah1> > Text<blah2>more</blah2>text. > </blah> > Comes out >=20 > Text text.more -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:11:10
|
You've obviously not been on the list long. There has been major = discussion about this. I will forward to you separetely the list of = emails relating to this topic. Nigel ----- Original Message -----=20 From: <ga...@wh...> To: <us...@li...> Sent: Friday, July 06, 2001 2:20 PM Subject: [phpXML] phpXML bug (I think!) > Hi, >=20 > We've been using your phpXML class in a project and have come across a > problem. Basically, this section of XML below: >=20 > <paragraph> > This is the first <bold>paragraph</bold>. A second is below > </paragraph> >=20 > When we read it in from a file, and do some work on the XML and then > re-export it as a file it becomes the following: >=20 > <paragraph> > This is the first . A second is below > <bold>paragraph</bold> > </paragraph> >=20 > This obviously isn't correct according to the way the XML went it (and = this > is an accepted thing to do as in an XML document as far as I am aware) = - it > appears that phpXML is taking elements that occur within other = elements > (when the parent element has data) and putting them at the end of the > parent's content. Has this problem been identified before and, if so, = does > anybody have a work-around for it as we're quite a way into the = project now > and we don't really want to remove phpXML from it. >=20 > If anybody does have any ideas I'd appreciate hearing them :) >=20 > Regards, >=20 > Gareth Lancaster >=20 >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:11:04
|
> <blah1> > Text<blah2>more</blah2>text. > </blah> >=20 > Just wondering if this is a correct xml data structure. =20 I'm pretty sure it is a well-formed XML structure. I'll research = sometime when I'm not at work, or I was hoping someone else would answer = this for me. Go check out www.w3c.org. It won't take long to confirm = either way. > Cause I haven't > seen somthing like this before. =20 <p><B>Marked up</B> bits of <strong>text</strong> will have this pattern = of elements and text <i>often</i></p>. > Or is this an output from phpXML? It couldn't possibly be the output from phpXML. As I have already = argued, the phpXML class is unable to represent such a structure = internally, so it can't output text of this form. > Can you > be a little bit more clear on this because i haven't encountered major > problems from phpXML except when I start using complex XPath. Many XML documents never use a mix of text and elements below a node, = hence you never see this issue. > I can easily write an xmlfile and read from an xmlfile but haven't = tested > the replace and delete node. I'm intrigued how you manage this. When I ask phpXML to get_file. It = escapes all the <> with < > and I get: <blah1> Text<blah2>more</blah2>text. </blah> This is not a well-formed XML document as it is both missing a <?xml = .... ?> bit (easily added) but it more annoyingly doesn't have a root = node, as the root node has been escaped by < and > so the blah1 = element is no longer an element but is now text. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:59
|
> Is it possible...? I am looking for the easiest way to preform simple xml > xslt html transformations I think trying to do XSLT with phpxml would be a bit of a nightmare. It would only really work for very specific and simple cases, so if you are happy with that then fire away. You are going to have to write a fair amount of PHP for each page in order to process an xml file with elements in an unpredictable order. I don't know what the phpxml users out there use it for, but I see it more as a method of making alterations to an existing xml document, and making and displaying XPath queries of an xml document. XSLT works by reading through the xml document from start to finish and processing the elements as it goes. Phpxml reads the whole xml document into an object that can then be queried. Trying to get an XSLT approach from phpxml is therefore clearly going to be difficult. I think that it would be easier to write a watered down XSLT processor from the basic XML parser functions, that phpxml is built upon, than to write one on top of phpxml. There might be some other php projects out there that might help, but I don't know of any to suggest. Presumably you don't have the "sablot" PHP XSLT library available to you? Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:56
|
Try using a context of /government[1] The context (I think) has to be a COMPLETE address. Not just an XPath = address that evaluates to only one node. I haven't tested this, but I think this is right. Nigel ----- Original Message -----=20 From: <tom...@di...> To: <us...@li...> Sent: Wednesday, July 04, 2001 2:29 PM Subject: [phpXML] Need example for 'context' > Hello all, >=20 > I need a very specific example for the use of 'context' in the = original=20 > distro examples. >=20 > What are inputs that show a highlighted result ? > "XPath Expression:" > "XPath Context:" >=20 > E.g. what input for each field in the form testsuite.php (processing = the=20 > 'government.xml' file) >=20 > Whaterver combination I use (just one example) > Example (my entries) > XPath Expression: file://prename=20 > XPath Context: /government/person > - I get no result highlighted >=20 > Many thanks, > Tom >=20 >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:51
|
If anyone is interested, you'll find a release of phpxml at http://sourceforge.net/projects/phpxmldb/ with most of the bugs and enhancements that have been requested in the 125 messages that have been posted here in the 3 weeks that this list has been alive. Release notes also avaliable containing a list of the changes since phpxml 1.0. http://sourceforge.net/project/shownotes.php?group_id=31522&release_id=44340 Sorry folks, I still haven't got my hands of a copy of this DIFF program that people keep talking about, otherwise I'd have include a DIFF too. Some 25% of the file differs from the original now, so a DIFF would probably be quite heavy going... I'd post this at the phpxml project at sourceforge, but I'm not a developer there as yet. The phpxmldb work relies on phpxml so it's not a completely stupid place to post it :o) As such ftp://129.215.200.115 will no longer be serving phpxml version 1.N.X Some of you might be interested in the phpxmldb work, you might want to take a look, but please don't innondate me with mails about it as it's only a wee pre-alpha baby, however comments about the direction of the project would be appreciated. :o) Best regards Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:47
|
> Eh, no, because that just gives me back "/publication/foo1[1]", > "/publication/foo2[1]" and so on. I just want the array of "foo1", > "foo2" returned. >=20 > On Wed, 18 Jul 2001, Ni...@Sw... wrote: > > /Publication/* The class doesn't support this. More accurately the evaluate() function = doesn't support this. You'll have to break into the $object->nodes = array to get this information if you are not happy with using string = processing on the XPath addresses. I'm afraid this isn't an XPath question. There is no magic XPath = expression that will do this for you. Try calling print_r($Object) and you will learn about the internal = structure of the class, and which array to examine. I would advise that = you do not use "back doors" into the class however, and that you use = string routines to obtain the array that you desire from running = evalutate('/publication/*'). Luckily/Unluckily PHP doesn't really = support the concept of 'private' class data. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:43
|
> Included in the attached test.zip file are 3 files: > > 1. test.php - an example script for this question > 2. xmlfile_faulty.xml - an xml file that does not work with test.php (ie. it > does not return the <sub> element as I intended > 3. xmlfile_good.xml - an xml file that works correctly with test.php > > The only difference between the two xml files is at the start of the DTD > (and the case of the elements)... > xmlfile_good.xml: > <!ELEMENT resp (response)> > > xmlfile_faulty.xml: > <!ELEMENT CANCEL (RESPONSE)> > > [BTW: is XPath case-sensitive? ie. should I change file://SUB to file://sub?] > > > Can anyone tell me how to change test.php to work with xmlfile_faulty.xml?? You seem to be looking for Sub not Subs in test.php. From my experiences phpxml is case sensitive to content, so it is probably case sensitive with element names too. It's easy enough to test. A friend of mine did some investigation and could find no evidence of cas-insensitive matching in the XPath spec. A weakness that we will have to address. I've not researched this myself yet though. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:40
|
//*[starts-with(name(),'image')] You could also use //*[contains(name(),'image')] but that will get = slightly different results. Please read the tutorial at ZVON that Michael recommended. You'll find = several answers there including this one. http://www.zvon.org/xxl/XPathTutorial/General/examples.html I'm not sure that phpxml supports starts-with(). If it doesn't then = make it :o) Nigel ----- Original Message -----=20 From: <an...@is...> To: <us...@li...> Sent: Wednesday, July 18, 2001 6:02 PM Subject: [phpXML] Another Xpath question > How can I select nodes according to a wildcard, i.e. select all nodes > that start with 'image'. I have nodes called 'image1', 'image2', > 'image3', and so on. Does XPath support this? >=20 > -Andrei >=20 > "Tomorrow the sun will rise. And who knows what the tide will bring?" > - Tom Hanks, in "Cast Away" >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:37
|
> Sorry if my question is stupid.. is this a fork ??? Yeah. I've asked Michael to make me a developer of the project, but as = yet no reply. In the mean time I though I'd do us all a service by = creating 1.N.X releases. I suppose technically it's a fork, but I'm = hoping that Michael will "approve" it and it will become version 1.1 at = some point in the future. Nobody wants a fork.... This project is suffering from lack of mail list archive, and list of = known bugs. I'm trying to provide that by the 1.N.X releases and the = change log. The 1.N.X releases contain what I believe to be all of the = bug fixes and extra functions that have been mailed to this list to = date. If there is a strong feeling from the members of this list that I should = not discuss 1.N.X releases on this list, then let me know and I'll stop = posting them. Given that there have been 20 or so downloads to date, I = would presume this isn't the case? Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:33
|
> Hope this isn't a silly question...why does the Reply-To e-mail header = > repeat itself almost fifty times in each e-mail I receive through this = > list? Can that be fixed? Bug in mail list software. This was covered last week in several = postings. Michael, could you post a list of "known bugs" or FAQs about this list. = We seem to be revisting the same ground over and over in the list. = Without an archive, there is no way we can have any grounds for = complaining when someone descovers an already known about bug. We are all busy people and we are going to saturate in re-answering old = questions and not progressing the phpxml class, which is after-all why = we are on the list! I'm developing a kind of bug reporting system at = www.carrubbers.org/scripts/explorerindex for a script that I am wanting = to publish. This is the project that I am using phpxml for. When I've = progressed that further you are welcome to a copy of the code if you = like. Better ideas anyone? Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:27
|
/Publication/* ----- Original Message -----=20 From: <an...@is...> To: <us...@li...> Sent: Wednesday, July 18, 2001 5:32 PM Subject: [phpXML] Help with XPath expression > What kind of XPath expression can I use to select the names of all the > child nodes? That is, given the following fragment: >=20 > <publication> > <foo1> > .. > </foo1> > <foo2> > .. > </foo2> > .. > </publication> >=20 > I want to get the names of all nodes under <publication>. >=20 > Thanks, >=20 > -Andrei > * How would this sentence be different if Pi was equal to three? * >=20 > -- > This message has been sent through the <phpXML/> user discussion list. = To unsubscribe, please visit = https://sslsites.de/mailinglisten/user/us...@li.../ >=20 -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:24
|
> I found that class supports get_name($node) method, but it operates = only > on individual nodes. Might be nice to have get_names($nodes) as well. So write one :o) Mail it round we all get to use it. I'll encorporate it into my version = too so that when I mail round 1.N.3 it'll have that in it too. Welcome to Open Source. It's not a license to sit back and be lazy, = it's an oppertunity to benefit from others hard work and to share your = own. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:21
|
Spotted a major blunder in 1.N.3. Well only major if you are using operators in your XPath searches. They all end up getting evaluated as mod as I missed the break statements from the switch block. This means you often get div/0 errors as false is interpreted as 0. Oops. Sorry :o) Also made what I think is quite an important optimisation to some of the evaluate() private functions so that searches with fully qualified node positions will take 3 less function calls than they were. http://sourceforge.net/projects/phpxmldb/ Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <nig...@us...> - 2001-10-09 13:10:17
|
> When I get the cdata content of an xml tag using phpxml it seems to strip > out the new line characters, is that true and if so how can I have them left > in? Platform is Win. What version of phpxml are you using. Check out version 1.N.X for the latest version. Version 1.N.X maintains much more whitespace than version 1.0. http://sourceforge.net/projects/phpxmldb/ If that version is still causing hassles, please send an xml example with the whitespace that is getting stripped and I'll see what I can do for a future 1.N.X release. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <Adm...@ne...> - 2001-10-09 04:21:13
|
<<test.zip>> Hi all, Included in the attached test.zip file are 3 files: 1. test.php - an example script for this question 2. xmlfile_faulty.xml - an xml file that does not work with test.php (ie. it does not return the <sub> element as I intended 3. xmlfile_good.xml - an xml file that works correctly with test.php The only difference between the two xml files is at the start of the DTD (and the case of the elements)... xmlfile_good.xml: <!ELEMENT resp (response)> xmlfile_faulty.xml: <!ELEMENT CANCEL (RESPONSE)> [BTW: is XPath case-sensitive? ie. should I change //SUB to //sub?] Can anyone tell me how to change test.php to work with xmlfile_faulty.xml?? Regards, Addam Breen |
From: <Adm...@ne...> - 2001-10-09 04:07:15
|
ah... i thought i had tried with //SUB and //sub, but evidently not. xml->evaluate() is INDEED case-sensitive! Thanks Nigel, Addam -----Original Message----- From: Ni...@Sw... [mailto:Ni...@Sw...] Sent: Thursday, 19 July 2001 10:46 AM To: us...@li... Subject: [phpXML] Help with DTDs? > Included in the attached test.zip file are 3 files: > > 1. test.php - an example script for this question > 2. xmlfile_faulty.xml - an xml file that does not work with test.php (ie. it > does not return the <sub> element as I intended > 3. xmlfile_good.xml - an xml file that works correctly with test.php > > The only difference between the two xml files is at the start of the DTD > (and the case of the elements)... > xmlfile_good.xml: > <!ELEMENT resp (response)> > > xmlfile_faulty.xml: > <!ELEMENT CANCEL (RESPONSE)> > > [BTW: is XPath case-sensitive? ie. should I change file://SUB to file://sub?] > > > Can anyone tell me how to change test.php to work with xmlfile_faulty.xml?? You seem to be looking for Sub not Subs in test.php. From my experiences phpxml is case sensitive to content, so it is probably case sensitive with element names too. It's easy enough to test. A friend of mine did some investigation and could find no evidence of cas-insensitive matching in the XPath spec. A weakness that we will have to address. I've not researched this myself yet though. Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <wl...@bl...> - 2001-10-08 18:35:00
|
By Using <!CDATA[ any <tagged> text ]] i've modified my xml.php version to detect weather there are html tags or other text that might ruin an xml document structure. modified xml.php included.. // From my previous email to the list Here's a little snippit from the xml.php I modified to accomodate the lack of CDATA creation in a node that contains characters that would otherwise make an XML document invalid. What do you think? Can you improve it? -When I call $xmlobj->get_file(); it will go through the $xmlobj->nodes array and format the XML document. -For every 'text' node it will scan for characters such as "<>&". -If it encounters such characters it will add the <![CDATA[ tag before and ]] tag after the 'text' node. -Else just write out the 'text' node. if (strspn($this->nodes[$root]["text"], "<>&") > 0) { // Add the character data to the XML data with CDATA tags around it. $xml .= $before." <![CDATA[\n"; $xml .= $before." ".$this->nodes[$root]["text"]."\n"; $xml .= $before." ]]>\n"; } else { // Add the character data to the XML data. $xml .= $before." ".$this->nodes[$root]["text"]."\n"; } Look for this comment in your xml.php under the get_file() function if you want to know where i put it. It's around line 355 // Add the character data to the XML data. -----Original Message----- From: rot...@ne... [mailto:rot...@ne...] Sent: Wednesday, July 04, 2001 12:13 AM To: us...@li... Subject: [phpXML] miss-match How can I get around phpXML's tendency to place tags inside regular text after the tag containing the text. i.e., <blah1> Text<blah2>more</blah2>text. </blah> Comes out Text text.more -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <o.t...@ab...> - 2001-10-08 18:30:16
|
Can anybody please help me with this? I think the removechild function doesn't work. THe XML file: <users> <user us_fullname="aa" us_username="a" us_password="a" us_workspace="RI" us_email="aa" /> <user us_fullname="rr" us_username="rr" us_password="rr" us_workspace="RI" us_email="rr" /> </users> $xml->removechild("/users[1]/user[1]"); Result: </> Oliver -----Original Message----- From: nig...@us... [mailto:nig...@us...] Sent: donderdag 27 september 2001 2:43 To: us...@li... Subject: [phpXML] Patches since 1.N.5 Complete list of changes todate. _____ 110c110 < return $this->exportAsXml($absoluteXPath[$index]); --- > return $this->exportAsXml($absoluteXPathArray[$index]); 219c219 < return setAttributes($absoluteXPath, $aNewAttributes); --- > return $this->setAttributes($absoluteXPath, $aNewAttributes); 221c221 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 248c248 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 537c537 < return evaluate($xPathQuery, $baseXPath); --- > return $this->evaluate($xPathQuery, $baseXPath); 560,561c560,561 < if(in_array($path,array_keys($this->nodes))) { < return array($path); --- > if(in_array($xPathQuery,array_keys($this->nodes))) { > return array($xPathQuery); 668c668 < * @param string $path Full document path of the node, the attributes --- > * @param string $xPathQuery Full document path of the node, the attributes 675c675 < return setAttributes($absoluteXPath, array($name => $value)); --- > return $this->setAttributes($absoluteXPath, array($name => $value)); 679,681c679,682 < * Version of setAttribute() that sets multiple windows. < * < * @see setAttribute() --- > * Version of setAttribute() that sets multiple attributes. > * > * @param $attributes associative array of attributes to set. > * @see setAttribute() 683c684 < function setAttributes($absoluteXPath, $attribute) { --- > function setAttributes($absoluteXPath, $attributes) { 687,690c688,692 < if (isSet($this->nodes[$path]['attributes'])) { < $this->nodes[$path]['attributes'] = array_merge($this->nodes[$path]['attributes'], $attributes); < } else { < $this->nodes[$path]['attributes'] = $attributes; --- > if (isSet($this->nodes[$absoluteXPath]['attributes'])) { > $this->nodes[$absoluteXPath]['attributes'] = > array_merge($this->nodes [$absoluteXPath]['attributes'],$attributes); > } else { > $this->nodes[$absoluteXPath]['attributes'] = $attributes; 692c694,695 < } --- > } > 712c715 < unset($this->nodes[$path]['attributes']); --- > unset($this->nodes[$absoluteXPath]['attributes']); 719c722 < unset($this->nodes[$path]['attributes'][$attribute]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$attribute]); 725c728 < unset($this->nodes[$path]['attributes'][$name]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$name]); 769c772 < return $this->nodes[$path]['text']; --- > return $this->nodes[$absoluteXPath]['text']; 816c819 < $ret = implode('', $this->nodes[$path]['text']); --- > $ret = implode('', $this->nodes[$absoluteXPath]['text']); 838c841 < return _setContent($absoluteXPath, $value); --- > return $this->_setContent($absoluteXPath, $value); 849c852 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 854c857 < return _setContent($absoluteXPath, $value, TRUE); --- > return $this->_setContent($absoluteXPath, $value, TRUE); 863c866 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 879c882 < _setContent($absoluteXPath, $newContent); --- > $this->_setContent($absoluteXPath, $newContent); 1997c2000 < if (ereg('^\w*$', $predicate)) { --- > if (ereg('^\w*$', $predicate)) { 3705c3708 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* _____ CVS was sick, so all these changes are as yet not in cvs... Nigel =========================== For the most recent version of phpxml, V1.N.X, and an archive of this list visit: http://www.sourceforge.net/projects/phpxmldb <http://www.sourceforge.net/projects/phpxmldb> -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <o.t...@ab...> - 2001-10-08 18:28:42
|
Hi, I think the removechild function doesn't work. THe XML file: <users> <user us_fullname="aa" us_username="a" us_password="a" us_workspace="RI" us_email="aa" /> <user us_fullname="rr" us_username="rr" us_password="rr" us_workspace="RI" us_email="rr" /> </users> $xml->removechild("/users[1]/user[1]"); Result: </> Oliver -----Original Message----- From: nig...@us... [mailto:nig...@us...] Sent: donderdag 27 september 2001 2:43 To: us...@li... Subject: [phpXML] Patches since 1.N.5 Complete list of changes todate. _____ 110c110 < return $this->exportAsXml($absoluteXPath[$index]); --- > return $this->exportAsXml($absoluteXPathArray[$index]); 219c219 < return setAttributes($absoluteXPath, $aNewAttributes); --- > return $this->setAttributes($absoluteXPath, $aNewAttributes); 221c221 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 248c248 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 537c537 < return evaluate($xPathQuery, $baseXPath); --- > return $this->evaluate($xPathQuery, $baseXPath); 560,561c560,561 < if(in_array($path,array_keys($this->nodes))) { < return array($path); --- > if(in_array($xPathQuery,array_keys($this->nodes))) { > return array($xPathQuery); 668c668 < * @param string $path Full document path of the node, the attributes --- > * @param string $xPathQuery Full document path of the node, the attributes 675c675 < return setAttributes($absoluteXPath, array($name => $value)); --- > return $this->setAttributes($absoluteXPath, array($name => $value)); 679,681c679,682 < * Version of setAttribute() that sets multiple windows. < * < * @see setAttribute() --- > * Version of setAttribute() that sets multiple attributes. > * > * @param $attributes associative array of attributes to set. > * @see setAttribute() 683c684 < function setAttributes($absoluteXPath, $attribute) { --- > function setAttributes($absoluteXPath, $attributes) { 687,690c688,692 < if (isSet($this->nodes[$path]['attributes'])) { < $this->nodes[$path]['attributes'] = array_merge($this->nodes[$path]['attributes'], $attributes); < } else { < $this->nodes[$path]['attributes'] = $attributes; --- > if (isSet($this->nodes[$absoluteXPath]['attributes'])) { > $this->nodes[$absoluteXPath]['attributes'] = > array_merge($this->nodes [$absoluteXPath]['attributes'],$attributes); > } else { > $this->nodes[$absoluteXPath]['attributes'] = $attributes; 692c694,695 < } --- > } > 712c715 < unset($this->nodes[$path]['attributes']); --- > unset($this->nodes[$absoluteXPath]['attributes']); 719c722 < unset($this->nodes[$path]['attributes'][$attribute]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$attribute]); 725c728 < unset($this->nodes[$path]['attributes'][$name]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$name]); 769c772 < return $this->nodes[$path]['text']; --- > return $this->nodes[$absoluteXPath]['text']; 816c819 < $ret = implode('', $this->nodes[$path]['text']); --- > $ret = implode('', $this->nodes[$absoluteXPath]['text']); 838c841 < return _setContent($absoluteXPath, $value); --- > return $this->_setContent($absoluteXPath, $value); 849c852 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 854c857 < return _setContent($absoluteXPath, $value, TRUE); --- > return $this->_setContent($absoluteXPath, $value, TRUE); 863c866 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 879c882 < _setContent($absoluteXPath, $newContent); --- > $this->_setContent($absoluteXPath, $newContent); 1997c2000 < if (ereg('^\w*$', $predicate)) { --- > if (ereg('^\w*$', $predicate)) { 3705c3708 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* _____ CVS was sick, so all these changes are as yet not in cvs... Nigel =========================== For the most recent version of phpxml, V1.N.X, and an archive of this list visit: http://www.sourceforge.net/projects/phpxmldb <http://www.sourceforge.net/projects/phpxmldb> -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <o.t...@ab...> - 2001-10-08 18:24:04
|
Nigel, What do you mean by this correction (or I don't see the difference): 1997c2000 < if (ereg('^\w*$', $predicate)) { --- > if (ereg('^\w*$', $predicate)) { Oliver -----Original Message----- From: nig...@us... [mailto:nig...@us...] Sent: donderdag 27 september 2001 2:43 To: us...@li... Subject: [phpXML] Patches since 1.N.5 Complete list of changes todate. _____ 110c110 < return $this->exportAsXml($absoluteXPath[$index]); --- > return $this->exportAsXml($absoluteXPathArray[$index]); 219c219 < return setAttributes($absoluteXPath, $aNewAttributes); --- > return $this->setAttributes($absoluteXPath, $aNewAttributes); 221c221 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 248c248 < return setAttributes($absoluteXPath, $attributes); --- > return $this->setAttributes($absoluteXPath, $attributes); 537c537 < return evaluate($xPathQuery, $baseXPath); --- > return $this->evaluate($xPathQuery, $baseXPath); 560,561c560,561 < if(in_array($path,array_keys($this->nodes))) { < return array($path); --- > if(in_array($xPathQuery,array_keys($this->nodes))) { > return array($xPathQuery); 668c668 < * @param string $path Full document path of the node, the attributes --- > * @param string $xPathQuery Full document path of the node, the attributes 675c675 < return setAttributes($absoluteXPath, array($name => $value)); --- > return $this->setAttributes($absoluteXPath, array($name => $value)); 679,681c679,682 < * Version of setAttribute() that sets multiple windows. < * < * @see setAttribute() --- > * Version of setAttribute() that sets multiple attributes. > * > * @param $attributes associative array of attributes to set. > * @see setAttribute() 683c684 < function setAttributes($absoluteXPath, $attribute) { --- > function setAttributes($absoluteXPath, $attributes) { 687,690c688,692 < if (isSet($this->nodes[$path]['attributes'])) { < $this->nodes[$path]['attributes'] = array_merge($this->nodes[$path]['attributes'], $attributes); < } else { < $this->nodes[$path]['attributes'] = $attributes; --- > if (isSet($this->nodes[$absoluteXPath]['attributes'])) { > $this->nodes[$absoluteXPath]['attributes'] = > array_merge($this->nodes [$absoluteXPath]['attributes'],$attributes); > } else { > $this->nodes[$absoluteXPath]['attributes'] = $attributes; 692c694,695 < } --- > } > 712c715 < unset($this->nodes[$path]['attributes']); --- > unset($this->nodes[$absoluteXPath]['attributes']); 719c722 < unset($this->nodes[$path]['attributes'][$attribute]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$attribute]); 725c728 < unset($this->nodes[$path]['attributes'][$name]); --- > unset($this->nodes[$absoluteXPath]['attributes'][$name]); 769c772 < return $this->nodes[$path]['text']; --- > return $this->nodes[$absoluteXPath]['text']; 816c819 < $ret = implode('', $this->nodes[$path]['text']); --- > $ret = implode('', $this->nodes[$absoluteXPath]['text']); 838c841 < return _setContent($absoluteXPath, $value); --- > return $this->_setContent($absoluteXPath, $value); 849c852 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 854c857 < return _setContent($absoluteXPath, $value, TRUE); --- > return $this->_setContent($absoluteXPath, $value, TRUE); 863c866 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* 879c882 < _setContent($absoluteXPath, $newContent); --- > $this->_setContent($absoluteXPath, $newContent); 1997c2000 < if (ereg('^\w*$', $predicate)) { --- > if (ereg('^\w*$', $predicate)) { 3705c3708 < * @param string $path Full document path of the node. *READONLY* --- > * @param string $xPathQuery Full document path of the node. *READONLY* _____ CVS was sick, so all these changes are as yet not in cvs... Nigel =========================== For the most recent version of phpxml, V1.N.X, and an archive of this list visit: http://www.sourceforge.net/projects/phpxmldb <http://www.sourceforge.net/projects/phpxmldb> -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |