Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.net XML Attributes

Posted on 2012-03-13
2
Medium Priority
?
316 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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