using xpath to locate and modify node?

View: New views
3 Messages — Rating Filter:   Alert me  

using xpath to locate and modify node?

by Jatayu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm using xerces-c 3.0.0 beta to experiment on how I can use its xpath
feature.

Does anyone know if it's possible to use XPATH to locate a node in the DOM,
then do *modification* on that returned node, e.g: add new children to that
node?

Something like:

  DOMXPathResult* xpathRes = (DOMXPathResult*)theDoc->evaluate(......);

But the "getSingleNodeValue<file:///u:/DataFpinitTier2_2/cgunadi/xml/xerces_3.0.0_linux24_amd64/xerces-c-3.0.0.b1/doc/html/apiDocs-3/classDOMXPathResult.html#745a4f5efb935a988d0b4ca6a46c0b0e>()"
function on DOMXPathResult returns
a *const* node.

Is it safe to cast away the const and add new children/change value
of the node?

Is there different way to accomplish this?

Thank you very much for any inputs.

Regards,
= Jatayu

Re: using xpath to locate and modify node?

by Boris Kolpackov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jatayu,

Jatayu <jatayu74@...> writes:

> Does anyone know if it's possible to use XPATH to locate a node in the DOM,
> then do *modification* on that returned node, e.g: add new children to that
> node?

Yes, that a pretty reasonable thing to do.


> function on DOMXPathResult returns a *const* node.

This has been fixed in SVN. The second beta (coming out in a few
weeks) will have this change.

> Is it safe to cast away the const and add new children/change value
> of the node?

Yes, that's what you can do in the meantime.

Boris

--
Boris Kolpackov, Code Synthesis Tools   http://codesynthesis.com/~boris/blog
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

Re: using xpath to locate and modify node?

by Jatayu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Boris,

Thank you again. This is very helpful.

= Jatayu


On Wed, Jun 25, 2008 at 1:06 PM, Boris Kolpackov <boris@...>
wrote:

> Hi Jatayu,
>
> Jatayu <jatayu74@...> writes:
>
> > Does anyone know if it's possible to use XPATH to locate a node in the
> DOM,
> > then do *modification* on that returned node, e.g: add new children to
> that
> > node?
>
> Yes, that a pretty reasonable thing to do.
>
>
> > function on DOMXPathResult returns a *const* node.
>
> This has been fixed in SVN. The second beta (coming out in a few
> weeks) will have this change.
>
> > Is it safe to cast away the const and add new children/change value
> > of the node?
>
> Yes, that's what you can do in the meantime.
>
> Boris
>
> --
> Boris Kolpackov, Code Synthesis Tools
> http://codesynthesis.com/~boris/blog<http://codesynthesis.com/%7Eboris/blog>
> Open source XML data binding for C++:
> http://codesynthesis.com/products/xsd
> Mobile/embedded <http://codesynthesis.com/products/xsdMobile/embedded>validating XML parsing:
> http://codesynthesis.com/products/xsde
>