Home > Archive > Oracle Server > July 2005 > Irritating XMLDOM issue









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Irritating XMLDOM issue
jonT

2005-07-28, 7:23 am

Hi,

Straightforward question: is there a way of getting a nodelist from an
XML document by providing an XPATH query, whereby the nodelist contains
handles onto the XML document rather than copies of the nodes?

More detail:

I have an XML document in the form of a dbms_xmldom.DOMDocument object
and am writing a PL/SQL query that enables one to change the values of
attributes across the document by specifying (1) the elements to edit,
(2) the attribute to edit and (3) the new value of the attribute.

I would like to specify (1) using an XPATH query: build a node list of
matching elements and then use the API to edit the elements. This would
be nice as the XPATH query offers a lot of flexibility.

The only relevant function appears to be "selectNodes()", used as
follows:

DocElement := dbms_xmldom. getDocumentElement(D
oc);
ElementToMatch := 'fooElementName& #91;@barAttributeNam
e=''someVal'']';
NodeList := dbms_XSLPROCESSOR. selectNodes(DocElemA
sNode,
ElementToMatch)

Now we have a node list that we can manipulate. Brilliant?! Well no.
selectNodes appears to give us a copy of the nodes, not handles into
the document. So the document is not updated when we do say:

dbms_xmldom. setNodeValue(Node,Ne
wAttrVal)

(where Node is some attribute of an element in NodeList).

I've got a solution working whereby I use " getChildrenByTagName
"
to build my nodelist:

NodeList := dbms_xmldom. getChildrenByTagName
(DocElement, TagName);

This works fine, but is very limited as you have to provide the tagName
and do lots of fiddling through the query to check that you are
manipulating only those nodes that you wish to. It lacks the elegance,
simplicity and flexibility of XPATH.

For reference, here is some documentation of XMLDOM:

http://www.lc.leidenuniv.nl/awcours...do5.htm#1025440

and here is some sample code for manipulating nodes:

http://saturn.uab.es/appdev.92 0/a96620/xdb08pls.htm
(search for Example 8-1 Creating and Manipulating a DOM Document)

Many thanks,

JonT

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com