Solved

VB.net XML Attributes

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS.net 2010 11 36
Need help making a program or form for inventory that exports to txt 8 41
export data table to excel in vb.net 10 27
location of a form 2 14
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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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