DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  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,649
    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, 08:33 AM
  2. Select Columns from XML File
    By Goth in forum XML
    Replies: 1
    Last Post: 07-18-2002, 05: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, 03:39 AM
  4. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM
  5. Get 10 months forward with select statment
    By Nirit Touboul in forum Database
    Replies: 7
    Last Post: 02-25-2001, 11:34 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links