【发布时间】:2013-07-08 23:12:27
【问题描述】:
我不知道为什么但是dom4j没有加载xmlns属性例如:
xmlns="http://webservices.example.com/servicesplatform/command/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
其他属性正常加载但被忽略。我使用属性迭代器检查所有元素的所有属性。
有一个例子我是如何阅读这个xml的:
SAXReader reader = new SAXReader();
Document document = reader.read(file);
return document;
我不知道我什至可以尝试什么。 :( 知道如何从 xml 文件中获取此属性吗? :(
编辑: 我就是这样遍历它们的
public void getAllAttributes(Element element) {
Iterator<Attribute> attributeterator = element.attributeIterator();
while (attributeterator.hasNext()) {
Attribute attribute = iteratorAttribute.next();
System.out.println(attribute.getQualifiedName() + " " + , attribute.getValue());
}
}
【问题讨论】:
-
如何遍历属性?你能把代码贴在你试图找到它们的地方吗?
标签: java xml xml-parsing dom4j