Answered Is it possible to convert XML into a Class?

  • Friday, April 28, 2006 8:44 AM
     
     

    Given an XML stream as below, is there any possibility to convert the same into any treditional class style with . (dots) as seperator of the nodes of the xml file...

    for instance

    bank.code.tostring() should reslut me "5070" and

    bank.description.tostring() should result "ICICI - Bangalore"

    bank.location.destination.code should result "MB"

    bank.location.zone.code.tostring() should result "12" etc .,

    And the XML file being ...

    <?xml version="1.0" encoding="utf-8" ?>

    <MainBank>

          <bank>

                <code>5070</code>

                <description>ICICI - Bangalore</description>

                <contactPerson>Peter Loke</contactPerson>

                <location>

                      <destination>

                            <code>MB</code>

                            <description>Main Branch at Mayohall</description>

                      </destination>

                      <zone>

                            <code>12</code>

                            <description>Admin building and 8to8Branch</description>

                      </zone>

                </location>

                <catagory>

                      <code>1LL</code>

                      <description>Admin with ExchRout plus Hub</description>

                </catagory>

                <exchContact>E839IRU</exchContact>

                <isTT>true</isTT>

                <classification>F98X</classification>

                <branchDets>

                      <code>8525</code>

                      <description>Administration Branch from 3rd_u70 ?loor Onwards</description>

                      <floors>3,4</floors>

                      <type>FA</type>

                      <description>

                            <detail>Fully Automated</detail>

                            <ATM>True</ATM>

                            <eTT>False</eTT>

                      </description>

                      <offices>

                            <offtype>

                                  <code>SA</code>

                                  <description>System Admin</description>

                            </offtype>

                            <currency>INR</currency>

                            <frCur>false</frCur>

                      </offices>

                </branchDets>

          </bank>

          <bank>

                <code>5071</code>

                <description>ICICI - Mumbai</description>

                <contactPerson>Jane Edwards</contactPerson>

                <location>

                      <destination>

                            <code>MB</code>

                            <description>Main Branch at VT</description>

                      </destination>

                      <zone>

                            <code>12</code>

                            <description>Admin building and 8to8Branch</description>

                      </zone>

                </location>

                <catagory>

                      <code>1LL</code>

                      <description>Admin with ExchRout plus Hub</description>

                </catagory>

                <exchContact>E839IRU</exchContact>

                <isTT>true</isTT>

                <classification>F98X</classification>

                <branchDets>

                      <code>8525</code>

                      <description>Administration Branch from 3rd_u70 ?loor Onwards</description>

                      <floors>3,4,5,6</floors>

                      <type>FA</type>

                      <description>

                            <detail>Fully Automated</detail>

                            <ATM>True</ATM>

                            <eTT>False</eTT>

                      </description>

                      <offices>

                            <offtype>

                                  <code>SA</code>

                                  <description>System Admin</description>

                            </offtype>

                            <currency>INR</currency>

                            <currency>USD</currency>

                            <frCur>True</frCur>

                      </offices></branchDets></bank></MainBank>

     

All Replies

  • Friday, April 28, 2006 9:42 AM
     
     

    You can write something that generates the class for you and populates it.  If the XML is known and you generate the class first, it will be easier.

     

  • Friday, April 28, 2006 11:11 AM
     
     
    Any idea about how can i generate the class first... i know the xml.. can you pl, through a little more light ?
  • Friday, April 28, 2006 1:58 PM
     
     

     

    hi

     i think you cant convert this xml to class, because xml should compatable with Dataset, then only you can convert to class, any this is the tool to convert xml in to class.

    xsd.xml

    class to schema conversion and schema to class conversion.

     

       -thanks

  • Friday, April 28, 2006 5:03 PM
     
     

    The xsd.exe is at.

    C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe

     

    You may be able to run it when you run the Visual Studio 2005 Command Prompt.

  • Saturday, April 29, 2006 6:21 AM
     
     
    Unfortunately we are still working with Visual studio 2003. Any othe way?
  • Saturday, April 29, 2006 6:25 AM
     
     Answered

    Hi,

    VS2003 is at:

    C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\xsd.exe

  • Saturday, April 29, 2006 8:11 AM
     
     
    Thanks ... I could convert .XML into .CS file. But now, the problem is... how can i use this class to extract the xml values?
  • Saturday, April 29, 2006 4:51 PM
     
     
  • Saturday, October 18, 2008 1:35 AM
     
     

    How to Convert XML into a Class?

    thank you!!!