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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing XML tag with attribute

Status
Not open for further replies.

kristof

Programmer
Jun 2, 2000
234
0
0
BE
Hi,

I'm using ReadXml() in combination with a XmlDataDocument and have an incoming XML tag like this:

<phonenumber type="1">somephonenumber</phonenumber>

So, I have this:

XmlDataDocument xmlDoc = new XmlDataDocument();

int i = 0;
foreach (DataRow row in doc.DataSet.Tables[0].Rows)
{
...
}

It'd be cool to be able to use something like:

phonenumber = row["phonenumber"].ToString();
type = row["type"].ToString();

But apparently it's not that simple.

I made a quick-fix solution using substring, but I'm sure there must be a more elegant way to deal with this, any ideas?

Thx
 
Nevermind, I found the solution.

Now that my deadline is behind me I had some time to look into it again and I realised there's also a xmlDoc.DataSet.Tables[1] available, which contains the attribute values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top