473,778 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Attribute name

Hiya

I have a nodeReader object that I am looping through in order to retrieve
the values from the attributes, but now I need the attribute name as well,
does anyone know how to do this? I will post the code I have below:
--------------------------
'// Element example: <TextBox parent='Form' Name='txtTitle' Top='56'
Width='100' Left='152' Text='Title' />

Dim pi As System.Reflecti on.PropertyInfo
Dim t1 As Type = myTextBox.GetTy pe

For i = 1 to nodeReader.Attr ibuteCount
pi = t1.GetProperty( **Need to get the Attribute value here. Eg: Name**)
pi.SetValue(myT extBox, nodeReader.GetA ttribute(i).ToS tring, Nothing)
Next
-------------------------

I'm sure you can see from the example, I am trying to loop through all the
attributes in my element in an XML file and set the properties of the
TextBox. I would prefer to do it this way so all I need to do in the future
is add in an appropriate attribute and value and my program will pick it up
automatically. The GetAttribute gets my value but I just need a way to get
the name of the attribute.

Thanks

Kind Regards,
Steve.
Nov 22 '05 #1
3 1781
Steve <stevea@centuri on-ms_RemoveThis_. co.uk> wrote:
I have a nodeReader object that I am looping through in order to retrieve
the values from the attributes, but now I need the attribute name as well,
does anyone know how to do this? I will post the code I have below:
--------------------------
'// Element example: <TextBox parent='Form' Name='txtTitle' Top='56'
Width='100' Left='152' Text='Title' />

Dim pi As System.Reflecti on.PropertyInfo
Dim t1 As Type = myTextBox.GetTy pe

For i = 1 to nodeReader.Attr ibuteCount
pi = t1.GetProperty( **Need to get the Attribute value here. Eg: Name**)
pi.SetValue(myT extBox, nodeReader.GetA ttribute(i).ToS tring, Nothing)
Next
-------------------------

I'm sure you can see from the example, I am trying to loop through all the
attributes in my element in an XML file and set the properties of the
TextBox. I would prefer to do it this way so all I need to do in the future
is add in an appropriate attribute and value and my program will pick it up
automatically. The GetAttribute gets my value but I just need a way to get
the name of the attribute.


You can use XmlNodeReader.M oveToAttribute and then use the Name
property, I believe. If you look at the sample code for
XmlNodeReader.H asAttributes it does the kind of thing you want.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
Hi Jon

Your my saviour again :o)

Thank you,
Steve.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Steve <stevea@centuri on-ms_RemoveThis_. co.uk> wrote:
I have a nodeReader object that I am looping through in order to retrieve the values from the attributes, but now I need the attribute name as well, does anyone know how to do this? I will post the code I have below:
--------------------------
'// Element example: <TextBox parent='Form' Name='txtTitle' Top='56'
Width='100' Left='152' Text='Title' />

Dim pi As System.Reflecti on.PropertyInfo
Dim t1 As Type = myTextBox.GetTy pe

For i = 1 to nodeReader.Attr ibuteCount
pi = t1.GetProperty( **Need to get the Attribute value here. Eg: Name**) pi.SetValue(myT extBox, nodeReader.GetA ttribute(i).ToS tring, Nothing)
Next
-------------------------

I'm sure you can see from the example, I am trying to loop through all the attributes in my element in an XML file and set the properties of the
TextBox. I would prefer to do it this way so all I need to do in the future is add in an appropriate attribute and value and my program will pick it up automatically. The GetAttribute gets my value but I just need a way to get the name of the attribute.


You can use XmlNodeReader.M oveToAttribute and then use the Name
property, I believe. If you look at the sample code for
XmlNodeReader.H asAttributes it does the kind of thing you want.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3
After you're done make sure you call MoveToElement() if you want to keep
reading the XML parse tree.
--
_______________ _____
Klaus H. Probst, MVP
http://www.vbbox.com/
"Steve" <stevea@centuri on-ms_RemoveThis_. co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Jon

Your my saviour again :o)

Thank you,
Steve.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Steve <stevea@centuri on-ms_RemoveThis_. co.uk> wrote:
I have a nodeReader object that I am looping through in order to retrieve the values from the attributes, but now I need the attribute name as well, does anyone know how to do this? I will post the code I have below:
--------------------------
'// Element example: <TextBox parent='Form' Name='txtTitle' Top='56'
Width='100' Left='152' Text='Title' />

Dim pi As System.Reflecti on.PropertyInfo
Dim t1 As Type = myTextBox.GetTy pe

For i = 1 to nodeReader.Attr ibuteCount
pi = t1.GetProperty( **Need to get the Attribute value here. Eg: Name**) pi.SetValue(myT extBox, nodeReader.GetA ttribute(i).ToS tring, Nothing)
Next
-------------------------

I'm sure you can see from the example, I am trying to loop through all the attributes in my element in an XML file and set the properties of the
TextBox. I would prefer to do it this way so all I need to do in the future is add in an appropriate attribute and value and my program will pick
it
up automatically. The GetAttribute gets my value but I just need a way to get the name of the attribute.


You can use XmlNodeReader.M oveToAttribute and then use the Name
property, I believe. If you look at the sample code for
XmlNodeReader.H asAttributes it does the kind of thing you want.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3670
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc. And i have things to offer, and to request. And a lot of ideas, but who needs them.... here's an example (from type_struct.py):
0
2184
by: Carl | last post by:
Hi, I have found a way to map attributes (columns) to column headings. But this runs really slow. Is there a way to improve it? Thanks, Carl <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="stylesheet.xslt"?>
1
3287
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4
2936
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are defined in a different namespace from the element.
3
1974
by: Tony Johansson | last post by:
Hello!! Assume we have one base class called Vehicle and two derived classes called Car and Bus. I would be able to call method getName on an object of class Car or Bus and return back the name that is set for this class. Asking getName on an object of class Vehicle is of no interest. Assume we have an attribute called name of type string. Now to my question do you think it's right to put the name attribute in each
2
2974
by: Isz | last post by:
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all outputs into a nice XML file for the purpose of populating a flash navigation menu. <NewDataSet> <mainMenu_category menu_name="Home" menu_ID="1"> <menu menu_ID="1" />
0
1745
by: Woody | last post by:
I need to group some attribute for use in different types, but if I nest an attributegroup inside another one I miss the nested attribute in class generated with xsd.exe. For example if I use the following two schemas xsd.exe give me the same class. First Schema: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/"
1
2041
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
8
1888
by: patrizio.trinchini | last post by:
Hi All, I'would like to write an XSL transformation that changes the value of the atribute of a given element according to the value of another atttribute of the same element. For instance, given the following XML file: <?xml version="1.0" encoding="UTF-8"?> <sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
3557
by: Adam Donahue | last post by:
As an exercise I'm attempting to write a metaclass that causes an exception to be thrown whenever a user tries to access 'attributes' (in the traditional sense) via a direct reference. Consider: class X( object ): y = 'private value' def get_y( self ): return self.y
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.