Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 February 9th, 2004, 06:55 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML attributes

Hi!

I need to load attributes from an XML element, in a file like this:

<factura numero="000222">
   <cabecera>
      <emisor cif="12345687-J">
         <nombre>pepe</nombre>
  ...

I know how to acces to "numero", in a way like this:

myElement = doc.DocumentElement;
attrColl = myElement.Attributes;
attr = attrColl["numero"];

How must I do to obtain cif?

Regards

-------------------------------
World only exists into your mind.
 
Old February 9th, 2004, 07:57 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found it:

XmlNodeList nodes = doc.SelectNodes("/factura/cabecera/emisor/@*");
foreach(XmlNode node in nodes)
...


-------------------------------
World only exists into your mind.
 
Old February 9th, 2004, 07:59 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

foreach(XmlNode node in nodes)
   Console.WriteLine(node.Value);

-------------------------------
World only exists into your mind.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete a xml node with all attributes and s vishnu108mishra XML 2 November 14th, 2007 04:19 AM
copying xml attributes golddog XSLT 1 September 12th, 2007 01:05 PM
Retrieving xml attributes christianhau Classic ASP XML 0 July 19th, 2007 06:25 AM
Using xml elements as html attributes chipmaster XSLT 4 June 26th, 2007 10:22 AM
XML to XML, checking attributes raoulvb XSLT 4 December 9th, 2004 10:15 AM





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