1 Reply Latest reply: Aug 11, 2013 3:38 AM by 836548 RSS

    XML to delimited text

    Celvin Kattookaran

      Hi I'm a newbie to Java and would like to know whether this can be achieved.

       

      <Membername="West"

      HierarchyType="Disabled"

      >

      <Membername="California"

      >

      <AttributeMemberdimension="Population"

      name="33000000"

      />

      <UDA >Major Market</UDA>

      </Member>

      </Member>

       

      I tried getting it as a | delimited text and wrote this code

       

      NodeList AppList = doc.getElementsByTagName("Member") ;
        for(int i= 0; i <AppList.getLength() ; i ++)
        {
        Element MbrElement = (Element) AppList.item(i);
      
          NodeList UDAElmntLst = MbrElement.getElementsByTagName("UDA");
          
        for(int i1= 0; i1 <UDAElmntLst.getLength() ; i1 ++)
        {
          Element UDANmElmnt = (Element) UDAElmntLst.item(i1);
          System.out.println(MbrElement.getAttribute("name") + "|"+UDANmElmnt.getTextContent());
        }
        }
      

       

      What i expect is this

      California|Major Market

       

      and what i get is

      West|New Market

      California|Major Market

       

      Why is it giving me West? West doesn't have a UDA tag