aspose file tools*
The moose likes XML and Related Technologies and the fly likes How to get an element with XPath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to get an element with XPath?" Watch "How to get an element with XPath?" New topic
Author

How to get an element with XPath?

miki landon
Greenhorn

Joined: Sep 02, 2008
Posts: 5
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
Bartender

Joined: Oct 14, 2005
Posts: 18989
    
    8

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

Joined: Sep 02, 2008
Posts: 5
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
Bartender

Joined: Oct 14, 2005
Posts: 18989
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get an element with XPath?