Results 1 to 3 of 3

Thread: Trying to retrieve value from basic XML

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Posts
    308

    Question Trying to retrieve value from basic XML

    I have an XML file with the following:

    <AppSetting>
    ...
    Nothing of Interest
    ...
    </AppSetting>

    <Customer>
    ...
    <add key=”Bla” value=”South”/>
    ...
    </Customer>

    My goal is to check if the key “Bla” is equal to “South” from my code.
    If I put the key “Bla” in my AppSetting section then the following would work:
    ConfigurationSettings.AppSettings["Bla"] == “South”

    However, how can I access the value when it is placed inside the Customer Section? There must be some simple statement that can be used but I am unable to find anything besides getting Customer Section as a dictionary and going threw the setting [not something I want to do, only want that one value].

    Any clues [using C#]?

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    is this being declared in the web.config file? (if so, post the format of the file) or in some other xml document?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    you could just create a customers.xml file and read it
    Code:
    using System.Xml;
    
    XmlTextReader reader = new XmlTextReader(Server.MapPath("customers.xml"));
    
    while(reader.Read())
    {
       reader.MoveToContent();
       if (reader.NodeType == XmlNodeType.Element)
          Response.Write("<b><" + reader.Name + "></b><br>");
       if (reader.NodeType == XmlNodeType.Text)
          Response.Write(reader.Value + "<br>");
    }
    
    reader.Close();
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width