XML fille to List<>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • muquaddim@gmail.com

    XML fille to List<>

    Hello,
    I have a xml file like the following.

    <?xml version="1.0">
    <data>
    <idef units="Vin,Vout ,E">
    <i id="i1">
    <sample num="1">
    <sampledata value="2;3;7" />
    </sample>
    <sample num="2">
    <sampledata value="8;1;7" />
    </sample>
    </i>
    <i id="i33"<!-- The Id is totally random -->
    <sample num="1">
    <sampledata value="2;3;7" />
    </sample>
    <sample num="2">
    <sampledata value="6,2,5" />
    </sample>
    </i>
    <s id="s1">
    <sample num="1">
    <sampledata value="2" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </s>
    <s id="s2"><!-- The Id is totally random -->
    <sample num="1">
    <sampledata value="7" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </s>
    <e id="Ea">
    <sample num="1">
    <sampledata value="9" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="4" unit="k" />
    </sample>
    </e>
    <e id="Eb">
    <sample num="1">
    <sampledata value="1" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </e>
    </data>

    Now I want to parse it and make 10 List<from these.
    Lists are ,
    Ea: 9,4
    Eb: 1,8
    s1: 2,8
    s2: 7,8
    i1-Vin: 2,8
    i1-Vout:3,1
    i1-E:7,7
    i33-Vin: 2,6
    i33-Vout:3,2
    i33-E:7,5

    How to do this?
    What library should I use? is there any standard way to do this?
    Its a C# desktop application. Is there any way to directly use the
    xml file as multiple datasource??
    I need something which is faster. Casue the file is way too large
    15MB.
    Thanks
  • Martin Honnen

    #2
    Re: XML fille to List&lt;&gt;

    muquaddim@gmail .com wrote:
    Hello,
    I have a xml file like the following.
    >
    <?xml version="1.0">
    <data>
    <idef units="Vin,Vout ,E">
    <i id="i1">
    <sample num="1">
    <sampledata value="2;3;7" />
    </sample>
    <sample num="2">
    <sampledata value="8;1;7" />
    </sample>
    </i>
    <i id="i33"<!-- The Id is totally random -->
    <sample num="1">
    <sampledata value="2;3;7" />
    </sample>
    <sample num="2">
    <sampledata value="6,2,5" />
    </sample>
    </i>
    <s id="s1">
    <sample num="1">
    <sampledata value="2" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </s>
    <s id="s2"><!-- The Id is totally random -->
    <sample num="1">
    <sampledata value="7" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </s>
    <e id="Ea">
    <sample num="1">
    <sampledata value="9" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="4" unit="k" />
    </sample>
    </e>
    <e id="Eb">
    <sample num="1">
    <sampledata value="1" unit="k" />
    </sample>
    <sample num="2">
    <sampledata value="8" unit="k" />
    </sample>
    </e>
    </data>
    >
    Now I want to parse it and make 10 List<from these.
    Lists are ,
    Ea: 9,4
    Eb: 1,8
    s1: 2,8
    s2: 7,8
    i1-Vin: 2,8
    i1-Vout:3,1
    i1-E:7,7
    i33-Vin: 2,6
    i33-Vout:3,2
    i33-E:7,5
    Sorry, I don't see how these "lists" relate to the input XML.
    What kind of lists do you want to create? List<int>?
    What is Ea or Eb, part of a list, or some kind of variable name for a list?
    How to do this?
    Well the .NET framework has the low level but fast forwards only
    XmlReader API to parse XML. Then it has XPathDocument/XPathNavigator for
    XPath 1.0 based reading and navigation. .NET 3.5 also has LINQ to XML.

    I need something which is faster. Casue the file is way too large
    15MB.
    Faster than what?


    --

    Martin Honnen --- MVP XML

    Comment

    • muquaddim@gmail.com

      #3
      Re: XML fille to List&lt;&gt;

      On Jun 15, 7:09 am, Martin Honnen <mahotr...@yaho o.dewrote:
      muquad...@gmail .com wrote:
      Hello,
      I have a xml file like the following.
      >
      <?xml version="1.0">
      <data>
      <idef units="Vin,Vout ,E">
      <i id="i1">
      <sample num="1">
      <sampledata value="2;3;7" />
      </sample>
      <sample num="2">
      <sampledata value="8;1;7" />
      </sample>
      </i>
      <i id="i33"<!-- The Id is totally random -->
      <sample num="1">
      <sampledata value="2;3;7" />
      </sample>
      <sample num="2">
      <sampledata value="6,2,5" />
      </sample>
      </i>
      <s id="s1">
      <sample num="1">
      <sampledata value="2" unit="k" />
      </sample>
      <sample num="2">
      <sampledata value="8" unit="k" />
      </sample>
      </s>
      <s id="s2"><!-- The Id is totally random -->
      <sample num="1">
      <sampledata value="7" unit="k" />
      </sample>
      <sample num="2">
      <sampledata value="8" unit="k" />
      </sample>
      </s>
      <e id="Ea">
      <sample num="1">
      <sampledata value="9" unit="k" />
      </sample>
      <sample num="2">
      <sampledata value="4" unit="k" />
      </sample>
      </e>
      <e id="Eb">
      <sample num="1">
      <sampledata value="1" unit="k" />
      </sample>
      <sample num="2">
      <sampledata value="8" unit="k" />
      </sample>
      </e>
      </data>
      >
      Now I want to parse it and make 10 List<from these.
      Lists are ,
      Ea: 9,4
      Eb: 1,8
      s1: 2,8
      s2: 7,8
      i1-Vin: 2,8
      i1-Vout:3,1
      i1-E:7,7
      i33-Vin: 2,6
      i33-Vout:3,2
      i33-E:7,5
      >
      Sorry, I don't see how these "lists" relate to the input XML.
      What kind of lists do you want to create? List<int>?
      What is Ea or Eb, part of a list, or some kind of variable name for a list?
      >
      How to do this?
      >
      Well the .NET framework has the low level but fast forwards only
      XmlReader API to parse XML. Then it has XPathDocument/XPathNavigator for
      XPath 1.0 based reading and navigation. .NET 3.5 also has LINQ to XML.
      >
      I need something which is faster. Casue the file is way too large
      15MB.
      >
      Faster than what?
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      By the following,
      s2: 7,8
      i1-Vin: 2,8
      I meant

      List<ints2;
      List<inti1_Vin;

      I need it .net 1.1 dependent hardly 2.0 (if I don't find any way ).

      I was thinking if there is any tool or api which will directly output
      List<>. and I'll give the description of the xml data. May be in xml
      format.

      Thanks for the XPathDocument/XPathNavigator names.
      I'll check if that works for me.

      Comment

      • Joe Fawcett

        #4
        Re: XML fille to List&lt;&gt;


        <muquaddim@gmai l.comwrote in message
        news:15c91af1-9eb8-4a20-9a25-e252a9e34a31@d7 7g2000hsb.googl egroups.com...
        On Jun 15, 7:09 am, Martin Honnen <mahotr...@yaho o.dewrote:
        >muquad...@gmai l.com wrote:
        Hello,
        I have a xml file like the following.
        >>
        >
        List<ints2;
        List<inti1_Vin;
        >
        I need it .net 1.1 dependent hardly 2.0 (if I don't find any way ).
        >
        ..NET 1.1 doesn't support generics so you can't use 1.1 and List<T>.

        --

        Joe Fawcett (MVP - XML)




        Comment

        Working...