Thread: using xml data in codedom created class

  1. #1
    Registered User
    Join Date
    Jul 2009

    using xml data in codedom created class

    hi there!

    i'm creating c# class using codedom methods
    i have already generated:

    public class CRSHorizontalID

    public class Norway

    // value
    public const long name;

    bu the name of "public class Norway" should be read from xml document.. the name of class is in the xml node: <Country name="Norway" isoAlpha3="NOR" countryId="47" >

    does someone know how could i get the word "Norway" from xml(or xsd) to the:
    newClass = new CodeTypeDeclaration(className); ?

    thank you much

  2. #2
    ...and never returned. StainedBlue's Avatar
    Join Date
    Aug 2009
    using System.Xml.Linq;
    string countryName =
        p => (string)p.Attribute == (someId)
        p => (string)p.Attribute("name")
    newClass = new CodeTypeDeclaration(countryName);
    Note that the above requires you to know what you're looking for, otherwise you'll have to return an IEnumerable collection and iterate all values (which may be what you're looking for), the latter allows you to have an in memory representation of the xml document, allowing you to parse it with just c#
    Last edited by StainedBlue; 08-30-2009 at 11:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Send data with class
    By Ducky in forum Networking/Device Communication
    Replies: 6
    Last Post: 08-08-2009, 09:16 AM
  2. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  3. Replies: 1
    Last Post: 11-23-2003, 08:51 AM
  4. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM