How to select an Element of an xml file in Asp.net


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to select an Element of an xml file in Asp.net

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    16

    How to select an Element of an xml file in Asp.net

    Hi guys

    I need to assign elements in an xml file to a variable .

    I am not familiar with xml .

    If any body could provide me with some code I will appreciate it.

    Here is my code .

    @@@@@@@@@@@@@@@@@@@

    XmlDocument xmldoc = new XmlDocument();
    xmldoc.Load("myxmlfile.xml");

    @firstname = xmldoc.SelectElement("firstname");

    @lastname = xmldoc.SelectElement("lastname");

    @@@@@@@@@@@@@@@@@@@@

    I know my code is wrong, If any body suggest the write code??
    This project is developed in ASP.net using C#.

    Thanks In advance.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What does the XML file look like?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Does this help?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Nov 2007
    Posts
    16
    XML file look like

    <Controls>
    <AdFeatImage1>
    <FeaturePageId>1</FeaturePageId>
    <FeatureTypeId>1</FeatureTypeId>
    <LogThis>True</LogThis>
    <IP>'127.0.0.1'</IP>
    <BannerDomain>0</BannerDomain>
    </AdFeatImage1>
    <AdFeatImage2>
    <FeaturePageId>1</FeaturePageId>
    <FeatureTypeId>124</FeatureTypeId>
    <LogThis>True</LogThis>
    <IP>'127.0.0.1'</IP>
    <BannerDomain>0</BannerDomain>
    </AdFeatImage2>
    <AdFeatImage3>
    <FeaturePageId>1</FeaturePageId>
    <FeatureTypeId>123</FeatureTypeId>
    <LogThis>True</LogThis>
    <IP>'127.0.0.1'</IP>
    <BannerDomain>0</BannerDomain>
    </AdFeatImage3>
    </Controls>

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't see 'firstname' or 'lastname' elements in that file. Which elements do you want to extract?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Searching an XML file
    By Hallo2oo5 in forum XML
    Replies: 1
    Last Post: 04-24-2007, 09:33 AM
  2. Select Columns from XML File
    By Goth in forum XML
    Replies: 1
    Last Post: 07-18-2002, 06:46 PM
  3. Free ASP.NET Web Matrix Design/Editor Tool Released
    By ASPSmith Training in forum dotnet.announcements
    Replies: 0
    Last Post: 06-18-2002, 04:39 AM
  4. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 11:53 AM
  5. Get 10 months forward with select statment
    By Nirit Touboul in forum Database
    Replies: 7
    Last Post: 02-25-2001, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center