dom4j API讲解

Element是dom4j的一个核心元素.
其常用api如下:
1.add(Attribute attribute)
描述:Adds the given Attribute to this element.
向元素中添加指定的属性
2.add(CDATA cdata)
描述:Adds the given CDATA to this element.
向元素中添加指定的CDATA,(这样对于xml特殊字符也可以直接输出)
3.add(Entity entity)
描述:Adds the given Entity to this element.
向元素中添加指定的Entity
4.add(Namespace namespace)
描述:Adds the given Namespace to this element.
向元素中添加指定的命名空间
5.add(Text text)
描述:Adds the given Text to this element.
向指定的元素中添加文本
6.addAttribute(QName qName, String value)
描述:Adds the attribute value of the given fully qualified name.
为给定的Qname添加对应的属性值
7.addAttribute(String name, String value)
描述:Adds the attribute value of the given local name.
给元素添加一个属性,名称为name,值为value
8.public List elements()
描述:Returns the elements contained in this element. If this element does not contain any elements then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
返回这个元素中包含的元素,如果这个元素没有包含任何元素,这个方法返回一个空的list,这个list是被这个元素所返回的,所以list的改变会反射到这个元素上,尽管相反的情况并非如此。
9. List elements(String name)
描述:Returns the elements contained in this element with the given local name and any namespace.
返回这个元素下于指定名称和命名空间相同的的元素们
10.String elementText(String name)
11.attribute(String name)
描述:Returns the attribute with the given name
返回给定名称的属性
12.element(String name)
描述:Returns the first element for the given local name and any namespace.
返回该元素下与给定名称相同的第一个元素
13. String getText()
描述:Returns the text value of this element without recursing through child elements.
不递归子元素,返回该元素的文本值
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值