父节点么?
原来写了一个删除节点的方法:
//删除节点
public void removeNode(Document d, String nodeName, String nodeValue) {
NodeList nl = d.getElementsByTagName(nodeName);
Node parentNode = null;
Node tmp = null;
int i = nl.getLength();
for (int j = 0; j < i; j++) {
if (nl.item(j).getTextContent().equals(nodeValue)) {
//得到父节点
parentNode = nl.item(j).getParentNode();
tmp = nl.item(j);
}
}
parentNode.removeChild(tmp);
}
原来写了一个删除节点的方法:
//删除节点
public void removeNode(Document d, String nodeName, String nodeValue) {
NodeList nl = d.getElementsByTagName(nodeName);
Node parentNode = null;
Node tmp = null;
int i = nl.getLength();
for (int j = 0; j < i; j++) {
if (nl.item(j).getTextContent().equals(nodeValue)) {
//得到父节点
parentNode = nl.item(j).getParentNode();
tmp = nl.item(j);
}
}
parentNode.removeChild(tmp);
}
解决方案 »
- struts2上传图片,然后jsp页面显示图片,问题!
- 文件解析
- java技术交流群87540701
- 高薪求WEB高级开发&CRM人才
- 解读 Tomact5.0 关闭打印信息
- Could not open Hibernate Session for transaction????
- 哎,求助:wrapper can not find class dealer.Mydealer or class it depends on...
- 一个运行时的小问题
- 关于setCharacterEncoding的问题
- hibernate3配置运行后出现的问题.
- 请问tomcat配置数据源连接池,应该在项目目录中的web.xml中如何配置?
- 写了一个显示验证码的程序,把服务器建在window里是可以出来的,把服务器建在lunix下就不行了,why?
简单的讲就是提供了一个自动在xml文件与java物件mapping的机制既然这样的话,个人认为,如果调用了JAXB的实现后,应该就是Object的java编码结构了,与原来的xml结构有所区别了,不能从XML的结构去看待。所以,个人认为如果需要确定父子节点的问题,只能在进行JAXB转换之前,对XML节点进行判定,然后进行转换操作。Unmarshalling from a org.w3c.dom.Node: JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File( "nosferatu.xml")); Object o = u.unmarshal( doc );以上是对整个XML结构文件进行转换
还有就是对与一个XML节点进行转换,有方法如下:unmarshal(org.w3c.dom.Node node)
Unmarshal global XML data from the specified DOM tree and return the resulting content tree.