• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where to start with parsing XML

 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm finally able to consume web services through our proxy server and now I have a XML file. Where do I start with parsing? I'm confused by the plethora of parsers; SAX, DOM, XSLT, Xerces, etc., and don't know where to start.

If it makes a difference, I'm getting the XML from the National Weather Service to build a web page with the weather forecast. I don't want all our users constantly hitting the NWS website so I need to store this information. I'm thinking I need to populate a bean and store it in the context.

Any tips on how to get started? Am I on the right track?
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I stumbled onto this site. It seems like a decent approach, but I'm confused by this code:



What is that MyFile object in the last line? The page doesn't explain where this came from.

 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jk Robbins wrote:I'm finally able to consume web services through our proxy server and now I have a XML file.

What is the XML file you are getting from the web services. Are you mentioning about the SOAP wsdl file?

SAX and DOM are popular XML programming interfaces. If it's like you need to parse an XML file and store it in a cache, you can use either of them and extract data from the desired nodes.

SAX and DOM examples will be plenty on the internet or if you search this forum.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that site is just a quick overview of what you would do if you knew how to use JAXB. A proper treatment of JAXB would require... well, however many pages the JAXB tutorial requires. It's a lot. I thought I had a copy on my machine but I don't, but anyway I recommend having a look at it. Your google keywords are jaxb tutorial (of course).
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have been clearer. I'm using a REST call; no WSDL involved. This is what I have so far:



But now I'm not sure what to do with that Object created on line 34. I have a folder full of classes created by JAXB from the XSD file, including an ObjectFactory class, but don't know what the next step should be.

Any tips are welcome. Back to more tutorials...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic