Skip to main content

Java XML Parsing wit TreeWalker

1 reply [Last post]
jero_x
Offline
Joined: 2007-03-19

Hello,

I am having problems with getting values from xml file. For example I get xml file like this:

and now I need to get values for TYPE, OPTION and CODE_INTERROGATION, ...

I found program TreeWalker that can do that but I can't find some example that will help me.

Can anyone tell me how to do that with TreeWalker or with some other program?

Thanks for your help and hope to hear from you soon

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
oleksiys
Offline
Joined: 2006-01-25

Hi,

simple TreeWalker sample you can find here [1]. Playing with NodeFilter you can filter what you need. For more info on TreeWalker try to google "TreeWalker sample".

But if you have just simple xml document, not sure if TreeWalker is really required. You can read DOM tutorial [2], and see, may be you'll find easier solution for your usecase.

[1] http://www.java2s.com/Code/Java/XML/DemoTreeWalker.htm
[2] http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/index.html