Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2005, 10:50 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default fething attributes

Hi

I am doing xml parsing in ASP.NEt using c#.
i am getting prob with attributes.How to get attribut values.

my xml looks like


<PhoneList>
<Phone Number='12234' CID='244' />
</PhoneList>
<AsID>100</AsID>

my code is

XmlDocument xDoc = new XmlDocument();
xDoc.Load(strxml);
XmlNodeList asid = xDoc.GetElementsByTagName("AsID");


here i can get asid without any problem.How to get the Number and CID from above xml?
pl advice me

 
Old May 13th, 2005, 10:44 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Once you have a nodelist, you can access one node and its attributes:

XmlNodeList phone = xDoc.GetElementsByTagName("Phone");
phone[0].Attributes["Number"];
phone[0].Attributes["CID"];

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to handle several attributes? sebhoff XSLT 2 March 20th, 2007 02:47 AM
Elements and attributes Morrislgn XSLT 1 June 20th, 2005 11:13 AM
Elements w same name and their attributes supafly XSLT 1 May 30th, 2005 06:34 AM
Count Attributes? btado XSLT 1 January 27th, 2005 02:23 PM
XML attributes miguel.ossa C# 2 February 9th, 2004 07:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.