Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

where to start with parsing XML

 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 26793
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic