Solved

VB.net XML Attributes

Posted on 2012-03-13
2
313 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Murray Brown
ID: 37714584
thank you very much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

632 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