1.字符串dataxml值如下:
<form>
<hideArea><subject>超级管理员</subject>
<urgency>0</urgency>
<security>0</security>
</hideArea>
<checked>
<DynamicCheckbox value="1,4,7">基地组织,爆破中心,门岗7</DynamicCheckbox>
</checked>
</form>
2.获得节点属性值及子节点值
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
String destination = null;
Document doc = builder.parse( new ByteArrayInputStream(dataxml.getBytes()));
if(doc.getElementsByTagName("DynamicCheckbox").item(0).getFirstChild()!=null){
String dynamicCheckbox = doc.getElementsByTagName("DynamicCheckbox").item(0).getAttributes().item(0).getNodeValue(); //节点“DynamicCheckbox”第一个属性值,即“1,4,7”;
String dynamicCheckbox2 = doc.getElementsByTagName("DynamicCheckbox").item(0).getNodeValue(); //节点“DynamicCheckbox”第一个节点值,即“基地组织,爆破中心,门岗7”;
}
如果dataxml中含有中文:则
dataxml = "<?xml version=\"1.0\" encoding=\"gbk\"?>" +dataxml;