Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in XSL to flatten XML hierarchy?

I have the following structure to XML file:

<INSTANCE>
  <Sections>
    <Section>
      <Forms>
        <Form>
          <Control id="GroupHeading1">
            <Property/>
            <Property/>
          </Control>
          <Control id="GroupHeading2">
           <Property/>
            <Control id="TextBox">
              <Property/>
              <Property/>
            </Control>
          </Control>
        </Form>
      </Forms>
    </Section>
  </Sections>
</INSTANCE>

I am trying to deserialize this into C# object, but I don't need to preserve the hierarchy (which is making it difficult for me to deserialize).

Is there XSL that can transform this to un-nest the Controls, and if possible add an attribute to any child Control with ParentId=""?

Thank you for any guidance!

like image 364
user53885 Avatar asked Dec 19 '25 14:12

user53885


1 Answers

Given XML, the XmlSerializer can produce a graph of objects that hold the same instance data.
This is known as XML de-serialization

You need to look here :

  • Using the XmlSerializer Attributes
  • Serialization and Deserialization in ASP.NET with C#
like image 77
Saurabh Gokhale Avatar answered Dec 21 '25 06:12

Saurabh Gokhale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!