Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Getting to an internal xml node

Hey experts,

I want to get the value of the "desc" attribute of node Z00000774 in the following xml file (using org.w3c.dom):

<BillingSystem>
    <BillingSystemMetaData>
     <Transform>
      <MappingCodes>
        <ChargeCodes>
            <Z00000774 desc="TELEPHONE LINE CLASSIC - SUBSCRIPTION" />
            <Z00001059 desc="PHONE MAESTRO 300 ANTHRACITE V1" />
            <Z00001111 desc="FIXED RELOCATION COSTS" />
            <Z00001236 desc="RANGE OF 10 CALLING NUMBERS (DDI)" />
            <Z00003537 desc="RESTRICTION CONSULTEL SERVICE (090)" />
            <Z00004014 desc="RANGE OF 100 NUMBERS (DDI)" />
            <Z00006633 desc="NUMBER RETENTION FOR DDI" />
         </ChargeCodes>
       </MappingCodes>
    </Transform>
  </BillingSystemMetaData>
</BillingSystem>

I am trying  resultCode = doc.getElementsByTagName("Z00000774").item(0).getAttributes().item(0).getNodeValue();
but it's not working, any help on the correct java syntax that gets the value??
0
mte01
Asked:
mte01
  • 2
1 Solution
 
CEHJCommented:
String attribute = null;
NodeList nodes = doc.getElementsByTagName("Z00000774");
if (nodes.getLength() > 0) {
      attribute = ((Element)nodes.item(0)).getAttribute("desc");
}
      
0
 
mte01Author Commented:
>>CEHJ

That did the trick..thanks for your help!
0
 
CEHJCommented:
:-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now