Solved

VB.net XML Attributes

Posted on 2012-03-13
2
307 Views
Last Modified: 2012-03-13
Hi

How do I loop through the following VB.net code and use the GetAttributes to find the
key, descition, and parent of the following XML nodes


<REPORTS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
  <REPORTS key="REPORTS">
    <DESCRIPTION>REPORTS</DESCRIPTION>
    <UPDATED_ON>31 Jan 12  17:49</UPDATED_ON>
    <UPDATED_BY>admin</UPDATED_BY>
  </REPORTS>
  <FOLDER key="CLUSTER">
    <DESCRIPTION>Demo  Reports</DESCRIPTION>
    <PARENT>REPORTS</PARENT>
    <TYPE>REPORT FOLDER</TYPE>
    <IMAGE>BOOK_RED</IMAGE>
    <PUBLISHED>TRUE</PUBLISHED>
    <NOTE>Customised reports for demonstrations</NOTE>
    <SORT>1001</SORT>
  </FOLDER>
  <FOLDER key="PROCESSCONTROL">
    <DESCRIPTION>Process Control</DESCRIPTION>
    <PARENT>CLUSTER</PARENT>
    <TYPE>REPORT FOLDER</TYPE>
    <IMAGE>FOLDER</IMAGE>
    <PUBLISHED>TRUE</PUBLISHED>
    <SORT>1002</SORT>
  </FOLDER>
0
Comment
Question by:murbro
2 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 37714490
If your XML is ina variable xStringH then you can use LINQ to get these values, e.g
Dim Result = From x In xStringH.Descendants() Where Not String.IsNullOrEmpty(x.@key)
            Select New With {.xKey = x.@key,
                             .xParent = x.Name.LocalName,
                             .xDescription = x...<DESCRIPTION>.Value}

Open in new window

And you get the anonymous type:
result
0
 

Author Closing Comment

by:murbro
ID: 37714584
thank you very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net - CSV to Oracle table 4 52
Changing the Source of an ADO Recordset while it's open 4 36
Test ddwrt:UserLookup 1 53
Vb.Net Date Formatting Assistance 4 35
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now