This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes has anyone encountered this problem when using xpath Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "has anyone encountered this problem when using xpath" Watch "has anyone encountered this problem when using xpath" New topic
Author

has anyone encountered this problem when using xpath

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have run into a problem with part of my code ie. where I use XPath. For some reason its returning the portion of the node tree from where I make my request. eg.
Document dom = createDomFromXML(notificationXML);
String notificationBatchXPath = notifications/notification[@name='BATCH_NOTIFICATION'];
//notifications/notification[@name='BATCH_NOTIFICATION']
Node nodeBatch = XPathAPI.selectSingleNode((Node)dom, notificationBatchXPath);
where notificationXML is notifications.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<notifications>

<notification name='BATCH_NOTIFICATION'>
<columns>
<column>field_id</column>
<column>old_value</column>
<column>new_value</column>
</columns>
</notification>

<notification name='NEXT_WORKFLOW'>
<columns>
<column>field_id</column>
<column>old_value</column>
</columns>
</notification>

<notification name='HISTORY_WORKFLOW'>
<columns>
<column>field_id</column>
</columns>
</notification>
</notifications>
so in this request I would expect
<columns>
<column>field_id</column>
<column>old_value</column>
<column>new_value</column>
</columns>
but I get
<columns>
<column>field_id</column>
<column>old_value</column>
<column>new_value</column>
</columns>
<columns>
<column>field_id</column>
<column>old_value</column>
</columns>
<columns>
<column>field_id</column>
</columns>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: has anyone encountered this problem when using xpath
 
Similar Threads
Element with same name
Struts with parsers
Auditing Table
need help in pivot
Converting an application using xstl from struts to struts 2