Nigel,
Many thanks for that, it works a treat. Also interesting that once I'd done
that I got an error from phpXML that normalize-space() isn't supported by
the parser yet! But no worries, I removed that and it worked fine.
Thanks again - you're right the documentation isn't clear on this point but
now I know it, I'll not have the problem again!
Regards,
Gareth
> -----Original Message-----
> From: Ni...@Sw... [mailto:Ni...@Sw...]
> Sent: 09 July 2001 17:59
> To: us...@li...
> Subject: [phpXML] Re: [phpXML] Problems using element[@attribute='']
> syntax ??
>
>
> Have you tried:
>
> $aArray =
> $calendarXML->evalute("/calendar[1]/month[normalize-space(@number)
> ='01']/day[normalize-space(@number)='02']","entry");
> // ...You should really check that $aArray has exactly 1 element, then....
> $newNode = $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 -----
> From: <ga...@wh...>
> To: <us...@li...>
> Sent: Monday, July 09, 2001 5:45 PM
> Subject: [phpXML] Problems using element[@attribute=''] syntax ??
>
>
> > Hi,
> >
> > I can't, for the life of me, get the following working:
> >
> > $newNode =
> >
> $calendarXML->add_node("/calendar[1]/month[normalize-space(@number
> )='01']/da
> > y[normalize-space(@number)='02']","entry");
> > $calendarXML->add_content($newNode,"something");
> >
> > 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.
> >
> > Regards,
> >
> > Gareth
> >
> >
> >
> > --
> > 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.../
--
This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../
|