collapsing xml elements into attributes in c#
-
Hi, I have an 'in.xml' file which I would like to 'collapse' into an 'out.xml' file in c#. (Not necessarily asking for the code but the approach to do this ie. xslt or xmldocument add attributes) Many thanks in advance. The files are as follows: in.xml
2013-01-01 2014-12-31 100000.00 Genentech Pty Ltd 100000.00 150000.00 Acme Pty Ltd 25000.00 25000.00
150000.00
Mont Blanc Associates
50000.00
25000.00Acme Pty Ltd 10000.00 10000.00 Triple A Commercial 10000.00 10000.00
6
1
2
6
3
7
4
8
51
2Trevae, Srt, 3241
3
3241Silua, Rev, 2940 2 2940
Genentech Pty Ltd
7Acme Pty Ltd. 15 Triple A Commercial 9 Mont Blanc Associates 1
out.xml
-
Hi, I have an 'in.xml' file which I would like to 'collapse' into an 'out.xml' file in c#. (Not necessarily asking for the code but the approach to do this ie. xslt or xmldocument add attributes) Many thanks in advance. The files are as follows: in.xml
2013-01-01 2014-12-31 100000.00 Genentech Pty Ltd 100000.00 150000.00 Acme Pty Ltd 25000.00 25000.00
150000.00
Mont Blanc Associates
50000.00
25000.00Acme Pty Ltd 10000.00 10000.00 Triple A Commercial 10000.00 10000.00
6
1
2
6
3
7
4
8
51
2Trevae, Srt, 3241
3
3241Silua, Rev, 2940 2 2940
Genentech Pty Ltd
7Acme Pty Ltd. 15 Triple A Commercial 9 Mont Blanc Associates 1
out.xml
An xslt would be a simple way to achieve this with a well defined schema. If you're not comfortable with xslt though, you could easily do this with something like XLinq as well.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
An xslt would be a simple way to achieve this with a well defined schema. If you're not comfortable with xslt though, you could easily do this with something like XLinq as well.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Thanks. Do you agree the following summarizes what I am trying to achieve? Unless the child element has a child element of its own, make it an attribute of the parent.
---------------------------------------------------------- Lorem ipsum dolor sit amet.
It certainly looks like it.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Hi, I have an 'in.xml' file which I would like to 'collapse' into an 'out.xml' file in c#. (Not necessarily asking for the code but the approach to do this ie. xslt or xmldocument add attributes) Many thanks in advance. The files are as follows: in.xml
2013-01-01 2014-12-31 100000.00 Genentech Pty Ltd 100000.00 150000.00 Acme Pty Ltd 25000.00 25000.00
150000.00
Mont Blanc Associates
50000.00
25000.00Acme Pty Ltd 10000.00 10000.00 Triple A Commercial 10000.00 10000.00
6
1
2
6
3
7
4
8
51
2Trevae, Srt, 3241
3
3241Silua, Rev, 2940 2 2940
Genentech Pty Ltd
7Acme Pty Ltd. 15 Triple A Commercial 9 Mont Blanc Associates 1
out.xml
Yeah, time to practice some XSLT-Fu. :cool:
-
Yeah, time to practice some XSLT-Fu. :cool:
-
i hate you. your reply is funny but limited in usefulness. :cool:
---------------------------------------------------------- Lorem ipsum dolor sit amet.
I disagree. I feel his post was the most usefull of all, instructing you to increase your skillset. This would have the effect of you being able to solve this particular problem in a far more efficient method than posting a question in a discussion forum. :-D
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
I disagree. I feel his post was the most usefull of all, instructing you to increase your skillset. This would have the effect of you being able to solve this particular problem in a far more efficient method than posting a question in a discussion forum. :-D
A guide to posting questions on CodeProject[^]
Dave KreskowiakDave Kreskowiak wrote:
increase your skillset
Actually, I assumed he was already at least somewhat familiar with XSLT; he seems to know what it is and that it is applicable to the situation. I think what I meant to imply was that he should maybe become more confortable with XSLT. Oh, and OP: we do have an XML/XSLT forum if you need assistance group therapy.
-
i hate you. your reply is funny but limited in usefulness. :cool:
---------------------------------------------------------- Lorem ipsum dolor sit amet.
swjam wrote:
funny but limited in usefulness
Ah, good, you know XSLT already. :thumbsup:
-
Dave Kreskowiak wrote:
increase your skillset
Actually, I assumed he was already at least somewhat familiar with XSLT; he seems to know what it is and that it is applicable to the situation. I think what I meant to imply was that he should maybe become more confortable with XSLT. Oh, and OP: we do have an XML/XSLT forum if you need assistance group therapy.
I was just joking around. Either way, it wouldn't hurt to increase his skillset anyway.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
swjam wrote:
funny but limited in usefulness
Ah, good, you know XSLT already. :thumbsup:
I thought the
I hate you
was more indicative of XSLT kowledge!Never underestimate the power of human stupidity RAH
-
I thought the
I hate you
was more indicative of XSLT kowledge!Never underestimate the power of human stupidity RAH
To quote Billy Joel: "You may be right."