Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using XPath with the XML DOM

Former Member
0 Likes
980

I have just started to use the XML DOM API. One thing I cannot see yet is an easy way to use XPath to get the value of an element.

What I would like to do is pass an XPath expression like this:

\EDIFACT\ORDERS\NAD[2]\NAD01\NAD0102

into a method, and get the value of the element returned to me.

Does anybody know if there is a method of one of the DOM interfaces that would provide that kind of functionality, or am I going to have to traverse the nodes of the DOM tree manually to do this?

BR,

Tony.

3 REPLIES 3
Read only

Former Member
0 Likes
651

Hi Tony,

I read your posted question - I have the same problem.

I think that the method find_from_path_ns (or find_from_path) is the only "xpath"-like way to get a value.

BUT the syntax is very limited so you cannot use all good features of xpath

To traverse the nodes manually is (in my problem) unpractible - the xml-structures are different and it's horrible to traverse the tree.

I need xpaths like ' //x/y[3]/z[a='MS']' . I know, the performance is not very good but for small XML-messages fast enough

Do you have any solutions?

regards

Wolfgang Hummel

Read only

0 Likes
651

Hi,

Yes, I do have a solution, but I had to write my own code to do it. It works for me, but may not give you all the functionality that you want.

I want to post the result in a blog that I am trying to create withing the next week. I'll post a link here when it is done. The source code will be included.

BR,

Tony.

Read only

0 Likes
651


Hi,

do you know if SAP improve the path specification. I would like to read XML nodes with path like Document/CstmrPmtStsRpt/OrgnlPmtInfAndSts[n] with function FIND_FROM_PATH and for the momento is imposible.

BR,

María