jdom and xml parsing, part 2
jdom makes xml manipulation in java easier than ever. 【程序编程相关:对话框到子控件的切换】
by jason hunter 【推荐阅读:用WebWork、JSP、Velocit】
working with namespaces 【扩展信息:JDBC接口技术】
in the first article of this series, i introduced jdom, an open-source library for java-optimized xml data manipulations. i explained how this alternative document object model was not built on dom or modeled after dom but was created to be java-specific and thereby take advantage of java´s features, including method overloading, collections, reflection, and familiar programming idioms. i covered the important classes and started examining how to use jdom in your applications. in this article, i´ll take a look at xml namespaces, resultsetbuilder, xslt, and xpath.
jdom provides robust, native support for xml namespaces. jdom was created after the namespace recommendation was published, so unlike other apis there´s no pre-namespace and deprecated leftovers. (see the sidebar "xml namespaces" for more on namespaces.) in jdom, namespaces are represented by a namespace class:
namespace xhtml = namespace.getnamespace( "xhtml", "http://www.w3.org/1999/xhtml");
during construction, an object is given a name and can optionally be given a namespace:
elt.addcontent(new element("table", xhtml));
... 下一页