Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get an element with XPath?

 
miki landon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an xml file I would like to update everytime there's a change.

I would like to change the start element from time to time.
But I can't get the start node, it's only returning as a String.
Can someone please help me with this.



Here is my code
 
Paul Clapham
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code isn't very helpful, because we can't tell what XPath expression you are using. Perhaps the code doesn't produce the expression you think it does.
 
miki landon
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the xpath expression when i output from "search". Hope this will help you



I have tested my xpath in altova and they have a correct result which is



 
Paul Clapham
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see your problem... you think that the toString() method of an Element will convert the Element and all of its children to XML and return that. But it doesn't. It just returns the node value. For the node value of various kinds of nodes see the API documentation for org.w3c.dom.Node; in particular notice what the node value of an Element is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic