jdom and xml parsing, part 1 【程序编程相关:让XDoclet为你写存根类】
【推荐阅读:PHP PEAR中Database(DB】jdom makes xml manipulation in java easier than ever. 【扩展信息:会员管理系统中会员类的实现】
by jason hunter
chances are, you´ve probably used one of a number of java libraries to manipulate xml data structures in the past. so what´s the point of jdom (java document object model), and why do developers need it?
jdom is an open source library for java-optimized xml data manipulations. although it´s similar to the world wide web consortium´s (w3c) dom, it´s an alternative document object model that was not built on dom or modeled after dom. the main difference is that while dom was created to be language-neutral and initially used for javascript manipulation of html pages, jdom was created to be java-specific and thereby take advantage of java´s features, including method overloading, collections, reflection, and familiar programming idioms. for java programmers, jdom tends to feel more natural and "right." it´s similar to how the java-optimized rmi (remote method invocation) library feels more natural than the language-neutral corba (common object request broker architecture).
you can find jdom at jdom.org under an open source apache-style (commercial-friendly) license. it´s collaboratively designed and developed and has mailing lists with more than 3,000 subscribers. the library has also been accepted by sun´s java community process (jcp) as a java specification request (jsr-102) and is on track to become a formal java specification.
the articles in this series will provide a technical introduction to jdom. this article provides information about important classes. the next article will give you a feel for how to use jdom inside your own java programs.
oracle xml tools
the xml developer kit (xdk) is a free library of xml tools that oracle provides for developers. it includes an xml parser and an xslt transformation engine that can be used with jdom. you can find lots of information about these tools at the oracle xml home page, oracle.com/xml.
to download the parser, look for the xml developer kit names "xdk for java." click on "software" in the left column for the download links. once you unpack the distribution, the file xalparserv2.jar contains the parser.
to configure jdom and other software to use the oracle parser by default, you need to set the jaxp javax.xml.parsers.saxparserfactory system property to oracle.xml.jax.jxsaxparserfactory. this tells jaxp that you prefer the oracle parser. the easiest way is at the command line:
... 下一页