Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. collapsing xml elements into attributes in c#

collapsing xml elements into attributes in c#

Scheduled Pinned Locked Moved C#
xmlcsharp
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Pete OHanlon

    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

    S Offline
    S Offline
    swjam
    wrote on last edited by
    #3

    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.

    P 1 Reply Last reply
    0
    • S swjam

      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.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #4

      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

      1 Reply Last reply
      0
      • S swjam

        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.00

          Acme Pty Ltd
            10000.00
            10000.00
          
          Triple A Commercial
            10000.00
            10000.00
        

        6

        1
        2
        6
        3
        7
        4
        8
        5

        1
        2

        Trevae, Srt, 3241
        3
        3241

        Silua, Rev, 2940
          2
          2940
        

        Genentech Pty Ltd
        7

        Acme Pty Ltd.
          15
        
        Triple A Commercial
          9
        
        Mont Blanc Associates
          1
        

        out.xml

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #5

        Yeah, time to practice some XSLT-Fu. :cool:

        S 1 Reply Last reply
        0
        • P PIEBALDconsult

          Yeah, time to practice some XSLT-Fu. :cool:

          S Offline
          S Offline
          swjam
          wrote on last edited by
          #6

          i hate you. your reply is funny but limited in usefulness. :cool:

          ---------------------------------------------------------- Lorem ipsum dolor sit amet.

          D P 2 Replies Last reply
          0
          • S swjam

            i hate you. your reply is funny but limited in usefulness. :cool:

            ---------------------------------------------------------- Lorem ipsum dolor sit amet.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #7

            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

            P 1 Reply Last reply
            0
            • D 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 Kreskowiak

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #8

              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.

              D 1 Reply Last reply
              0
              • S swjam

                i hate you. your reply is funny but limited in usefulness. :cool:

                ---------------------------------------------------------- Lorem ipsum dolor sit amet.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #9

                swjam wrote:

                funny but limited in usefulness

                Ah, good, you know XSLT already. :thumbsup:

                M 1 Reply Last reply
                0
                • P PIEBALDconsult

                  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.

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #10

                  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

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    swjam wrote:

                    funny but limited in usefulness

                    Ah, good, you know XSLT already. :thumbsup:

                    M Offline
                    M Offline
                    Mycroft Holmes
                    wrote on last edited by
                    #11

                    I thought the I hate you was more indicative of XSLT kowledge!

                    Never underestimate the power of human stupidity RAH

                    P 1 Reply Last reply
                    0
                    • M Mycroft Holmes

                      I thought the I hate you was more indicative of XSLT kowledge!

                      Never underestimate the power of human stupidity RAH

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #12

                      To quote Billy Joel: "You may be right."

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups