JDOM Programming Part 2

側面______

側面______

2016-02-19 14:15

岁数大了,QQ也不闪了,微信也不响了,电话也不来了,但是图老师依旧坚持为大家推荐最精彩的内容,下面为大家精心准备的JDOM Programming Part 2,希望大家看完后能赶快学习起来。

JDOM and XML Parsing, Part 2

By Jason Hunter

  JDOM makes XML manipulation in Java easier than ever.

  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.

  Working with Namespaces

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  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));

  

  If no namespace is given, the element is constructed in "no namespace." An element's namespace is an intrinsic part of its type, so JDOM ensures that its namespace doesn't change when it moves around the document. If an element has no namespace and moves under an element that has a namespace, it explicitly does not inherit the namespace. Sometimes that causes confusion until you learn to separate the textual representation from the semantic structure.

  The XMLOutputter class sorts out the namespace issues and ensures placement of all the "xmlns" declarations into the appropriate locations, even after a document's elements have been heavily shuffled around. By default, the class places the declarations where they're first necessary. If you want them declared further up the tree (in other Words, all declarations at the root), you can use the element.addNamespaceDeclaration() method to provide that guidance.

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  All JDOM element or attribute Accessor methods support an optional namespace argument indicating the namespace in which to look. This example points to the xhtml namespace:

  

展开更多 50%)
分享

猜你喜欢

JDOM Programming Part 2

编程语言 网络编程
JDOM Programming Part 2

《质量效应2》全视频攻略 part 2 (normandy)

电脑网络
《质量效应2》全视频攻略 part 2 (normandy)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

对YUI扩展的Gird组件 Part-2

Web开发
对YUI扩展的Gird组件 Part-2

《质量效应2》全视频攻略 part 1 (opening)

电脑网络
《质量效应2》全视频攻略 part 1 (opening)

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

《质量效应2》全视频攻略 part 6 (omega - afterlife)

电脑网络
《质量效应2》全视频攻略 part 6 (omega - afterlife)

《fifa足球经理2008》,-系列问题part2

电脑网络
《fifa足球经理2008》,-系列问题part2

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

CSS基础教程:水平对齐(text-align)

CSS基础教程:水平对齐(text-align)

抓屏技巧二三例

抓屏技巧二三例
下拉加载更多内容 ↓