Discussion:
Unable to create XML Attribute name multiple times with different values
(too old to reply)
p***@halcyontek.com
2013-05-16 09:48:32 UTC
Permalink
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
John B. Matthews
2013-05-16 18:25:30 UTC
Permalink
In article <5db372c3-217a-4b53-aaa5-***@googlegroups.com>,
***@halcyontek.com wrote:
[...]
My code is lengthy to post here since I have coded...
[...]
I have posted my issue in one of the Java social sites where I have
placed my code. Please refer this URL, and help me.
<http://stackoverflow.com/questions/16581916/>
Following the link produces this:

Page Not Found
This question was voluntarily removed by its author.
...

IIUC, you can restore your own question.

<http://meta.stackoverflow.com/a/43943>

Because your "code is lengthy," another approach might be to construct
an sscce, <http://sscce.org/>, that focuses narrowly on the problem
using the simplest possible test data.
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
Loading...