Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2716

Unable to create XML Attribute name multiple times with different values

Newsgroups comp.lang.java.help
Date 2013-05-16 02:48 -0700
Message-ID <5db372c3-217a-4b53-aaa5-15c55042e1e9@googlegroups.com> (permalink)
Subject Unable to create XML Attribute name multiple times with different values
From pradeep.p@halcyontek.com

Show all headers | View raw


I have to create XML from Excel selected columns. My Excel selected columns are as follows

My issue here is: if same tag with different attributes exists, they are not created in XML file.

  Column        Star XML Path                          Star Tag TC1-ECIN    --------------------------------------------------------------------------------
Process:DataArea:Credit:IndividualApp:Address qualifier="HomeAdd"  AddLine   ABC
Process:DataArea:Credit:IndividualApp:Address qualifier="HomeAdd"  AddLine   XYZ
Process:DataArea:Credit:IndividualApp:Address qualifier="Billing"  AddLine   MNO
Process:DataArea:Credit:IndividualApp:Address qualifier="Billing"  AddLine   PQR
Process:DataArea:Credit:IndividualApp:Address qualifier="Garage"   AddLine   123
Process:DataArea:Credit:IndividualApp:Address qualifier="Garage"   AddLine   789


Required output should be as follows:

<Process>
  <DataArea>
    <Credit>
       <IndividualApp>
         <Address qualifier="HomeAddress">
             <AddressLine>ABC</AddressLine>
             <AddressLine>XYZ</AddressLine>
          </Address>
          <Address qualifier="Billing">
           <AddressLine>MNO</AddressLine>
           <AddressLine>PQR</AddressLine>
         </Address>
         <Address qualifier="Garage">
           <AddressLine>123</AddressLine>
           <AddressLine>789</AddressLine>
         </Address>
       </IndividualApp>
     </Credit>
  </DataArea>
</Process>
</Address>

So far I have coded is creating the XML as below and skipping <Address qualifier="Billing"> and <Address qualifier="Garage">

<Process>
  <DataArea>
    <Credit>
       <IndividualApp>
         <Address qualifier="HomeAddress">
             <AddressLine>ABC</AddressLine>
             <AddressLine>XYZ</AddressLine>
          </Address>
        </IndividualApp>
     </Credit>
  </DataArea>
</Process>
</Address>

My code is lengthy to post here since I have coded
   1. Excel to read in Java 
   2. Finding Excel column index numbers and reading the contents
   3. Splitting Excel column value as

<Process>
  <DataArea>
    <Credit>
       <IndividualApp>
          <Address qualifier="HomeAdd">
            <AddLine>ABC</AddLine>
          </Address>
       </IndividualApp>
     </Credit>
  </DataArea>
</Process>

    4. setting levels to create the tags(root, parent, child, value,....

I have posted my issue in one of the Java social sites where I have placed my code. please refer this URL, and d help me

http://stackoverflow.com/questions/16581916/unable-to-create-xml-attribute-name-multiple-times-with-different-values

Back to comp.lang.java.help | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Unable to create XML Attribute name multiple times with different values pradeep.p@halcyontek.com - 2013-05-16 02:48 -0700
  Re: Unable to create XML Attribute name multiple times with different values "John B. Matthews" <nospam@nospam.invalid> - 2013-05-16 14:25 -0400

csiph-web