[phpXML] Re: [phpXML] Problems using element[@attribute=''] syntax ??
Brought to you by:
bs_php,
nigelswinson
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.../ |