• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Processing XML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Processing XML


  • Subject: Re: Processing XML
  • From: Arturo PĂ©rez <email@hidden>
  • Date: Tue, 13 Jan 2004 23:38:00 -0500

On Jan 13, 2004, at 11:12 PM, Greg Hulands wrote:

HI,
I have never had a need to parse xml before so I am not quite sure how to do it. I am implementing a credit card payment component for my system and the credit card gateway sends and receives xml documents. I can easily generate the xml in a component to send to the gateway, by I am not sure how to parse the returned xml document. Below is an example:



I don't know how much of a neophyte you are so I'll give a real basic tutorial here.


For parsing XML there are essentially two types of parsers. They are known as SAX parsers and
DOM parsers. SAX parsers are event-driven. They basically use a callback model to execute code
one writes whenever anything interesting happens in the XML that is being parsed. The DOM parsers
build the entire XML document into a tree structure in memory so that one may query it repeatedly.


SAX parsers are faster but in essence require a single pass through the document. One may not
request first this bit then that bit. DOM parsers use a lot of memory and tend to be a little
slower.


In reality, there is a third kind of parser. Just read the data into a big string and
run String.indexOf over it. For real simple stuff that may be sufficient.


WO comes with a DOM parse (it's called WOMessage.contentAsDOMDocument
http://developer.apple.com/documentation/WebObjects/Reference/API/com/ webobjects/appserver/WOMessage.html#contentAsDOMDocument()). That's what I always used and it was sufficiently
fast for my purposes (faster than some of the SAX parsers out there).


Another very popular choice amongst my former coworkers was JDOM.

----
WO in philadelphia - wanna cheesesteak with that?
Please visit webobjects.meetup.com.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Processing XML (From: Greg Hulands <email@hidden>)

  • Prev by Date: Re: Processing XML
  • Next by Date: Re: Processing XML
  • Previous by thread: Re: Processing XML
  • Next by thread: Re: Processing XML
  • Index(es):
    • Date
    • Thread