package com.panjun;
import java.io.InputStream;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Namespace;
import org.dom4j.io.SAXReader;
public class TestDom4j {
public static void main(String[] args) {
SAXReader saxReader = new SAXReader();
try {
InputStream ins = TestDom4j.class.getClassLoader().getResourceAsStream("com/panjun/1.xml");
Document document = saxReader.read(ins);
for (Object o : document.getRootElement().declaredNamespaces()) {
Namespace ns = (Namespace) o;
System.out.println("xmlns:" + ns.getPrefix() + "=/"" + ns.getURI() + "/"");
}
} catch (DocumentException e) {
e.printStackTrace();
}
}
}