Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and int

Status
Not open for further replies.

Haunter

Programmer
Jan 2, 2001
379
US
I need to be able to read an interger from an xml attribute. I am not see the answer. I have decoded the entire document except for this. Can anyone help

Code:
<report>
<Section>
			<Header bookmark="Header1">name</Header>
			<DataDir>c:\blaj\blac</DataDir>
			<Data type="file" bookmark="Insert_Graphic">
				<Identifier font="Arial" size="10"> 
					<name>gate</name>
					<ip_if>address_11</ip_if>				
				</Identifier>
				<Identifier font="Arial" size="10">
					<name>gate2</name>
					<ip_if>address_11</ip_if>
				</Identifier>
				<Identifier font="Arial" size="10">
					<name>Leader</name>
					<ip_if>address_11</ip_if>
				</Identifier>
				<Identifier font="Arial" size="10">
					<name>Victory</name>
					<ip_if>address_11</ip_if>
				</Identifier>
			</Data>
		</Section>
</report>

I need to get the size attribute into and int so I can use it in a function.

Code:
int strSize = nlIdentifier.Item(i).Attributes["size"].Value;
The above code gives me a string I have tried to cast it without success. I am in need of a bit of help
thanks


haunter@battlestrata.com
 
Try this:
Code:
int strSize = XmlConvert.ToInt32(nlIdentifier.Item(i).Attributes["size"].Value);
The XmlConvert class is made for this situation.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top