Click here to Skip to main content
16,016,613 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have been learning to work with xml and I'm now able to create my layout just fine but Im having issues getting attribute data from the category fields. Below is a look at my xml, I need help finding the easiest way to loop through each category and get the name and weather its set to true or false. Any help would be great.

XML
<HelpBox>
  <Categorys>
    <Category Selected="True" Name="Admin Tools"></Category>
    <Category Selected="False" Name="Scripts"></Category>
    <Category Selected="False" Name="Clipboard"></Category>
  </Categorys>
  <Actions>
    <Item Name="RDC" Icon="1" TaskType="Launch" Category="Admin Tools">
      <File>C:\Windows\System32\mstsc.exe</File>
      <Arg />
    </Item>
    <Item Name="MSRA" Icon="2" TaskType="Launch" Category="Admin Tools">
      <File>C:\Windows\System32\msra.exe</File>
      <Arg>offerra</Arg>
    </Item>
  </Actions>
</HelpBox>
Posted

1 solution

I figured it out.

VB
Using reader As XmlReader = XmlReader.Create("C:\Users\shuppz\Desktop\XmlTest.xml")
    While reader.Read()
        ' Check for start elements.
        If reader.IsStartElement() Then

            If reader.Name = "Category" Then
                ' Get name attribute.
                Dim xName As String = reader("Name")
                If xName IsNot Nothing Then
                    MsgBox(String.Format("  Has attribute name: {0}", xName))
                End If

            End If
        End If
    End While
End Using
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900