解析字符串化XML的多个属性

时间:2017-01-18 11:43:29

标签: java xml

下面是XML.I想要解析并获取id。但是想要那些具有INT值的ID。在下面的XML中有四个Ids标签。我想要那些没有valus作为n / a。

{
  "status": {
    "runStatus": "STOPPED"
  },
  "component": {
    "state": "STOPPED",
    "id": "9204b68d-0159-1000-7d8f-720592b2a2dd"
  },
  "id": "9204b68d-0159-1000-7d8f-720592b2a2dd",
  "revision": {
    "version": 10,
    "clientId": "ab010dd6-0159-1000-615b-f095502a7ceb"
  }
} 

我正在以这种方式解析xml并在设备响应中设置值(这是bean类)

<?xml version=\"1.0\" ?<xs:nml
xmlns:xs=\"http://www.netgear.com/protocol/transaction/NMLSchema-0.9\" src=\"nas\" dst=\"dpv_1349084626000\" locale=\"en-us\">
<xs:transaction ref_id=\"njl_id_991\" status=\"success\">
    <xs:response ref_id=\"njl_id_991\" status=\"success\">
        <xs:result
            xmlns:ns3=\"http://www.w3.org/2001/XMLSchema-instance\" ns3:type=\"xs:exResult\">
            <xs:get-s resource-type=\"Devices\">
                <Device_Collection>
                    <Device>
                        <alias>nas-1C-CA-AE</alias>                        
                        <id>3374</id>
                        <license>
                            <ExpiredTime>n/a</ExpiredTime>
                        <id>n/a</id>                             
                        </license>
                        <model>qwerty</model>
                        <online>true</online>
                    </Device>
        <Device>
                        <alias>nas-1C-CA-AE</alias>                        
                        <id>3375</id>
                        <license>
                            <ExpiredTime>n/a</ExpiredTime>
                        <id>n/a</id>                             
                        </license>
                        <model>qwerty1</model>
                        <online>true</online>
                    </Device>                       
                </Devices>
            </xs:get-s>
        </xs:result>
    </xs:response>
</xs:transaction>

}

0 个答案:

没有答案