我尝试用jdom2从我的xml中删除一个节点,但我找不到答案
我的xml是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<banque>
<compte idCompte="5646">
<numCompte>5646</numCompte>
<nom>Ludo</nom>
<solde>850</solde>
</compte>
<compte idCompte="4546">
<numCompte>4546</numCompte>
<nom>Antoine</nom>
<solde>9999.4</solde>
</compte>
我认为我需要定位属性idCompte并将其删除但我不知道如何执行此操作。
如果您有(简单)解决方案,我很高兴看到:)
答案 0 :(得分:0)
What you are trying to achieve is complex(multi-step process) in nature,
I can share with you the steps(algorithm) that you need to follow:
Step:1
You need to genearte the schema first:
Generate the schema from this online tool:
http://www.xmlforasp.net/CodeBank/System_Xml_Schema/BuildSchema/BuildXMLSchema.aspx
Step:2
Using these schema generate the Java classes:
using api tools like XMLBeans or JAXB
a) scomp -out employeeschema.jar employeeschema.xsd (Ref: http://xmlbeans.apache.org/)
b) xjc -d out customer.xsd (Ref: http://blog.bdoughan.com/2011/10/jaxb-xjc-imported-schemas-and-xml.html)
Step:3
Then follow below tutorial for your reference for in-depth CRUD operation that you want to perform on your XML:
Jaxb: http://www.mkyong.com/java/jaxb-hello-world-example/
Xstream: http://x-stream.github.io/tutorial.html
XMLBeans: http://xmlbeans.apache.org/documentation/tutorial_getstarted.html