Solved

VB.net XML Attributes

Posted on 2012-03-13
2
304 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

21 Experts available now in Live!

Get 1:1 Help Now