Help convert VB LINQ to XML to C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,

I have this method in VB and I am rewriting my program in C#. I need some help with conversion.

Here is my xml;

<SiteInformation>
Other elements.......
<TaskHeaders>
<Header Owner="ProjectOwner" Name="Setup Package Setup</Header>
<Header Owner="Packager" Name="Creation Package Creation</Header>
<Header Owner="QController" Name="QCT Quality Control Testing</Header>
<!--<Header Owner="QController" Name="QC Quality Testing</Header>-->
<Header Owner="ProjectOwner" Name="UAT Requestor Testing and Approval</Header>
<Header Owner="ProjectOwner" Name="Release Release Management</Header>
</TaskHeaders>


</SiteInformation>



Here is the method Im trying to convert.

Public Shared Sub SetTaskHeaders()
Dim lstHeaders As New Collections.Hashtable
Try
xmlDoc = XDocument.Load(Application.StartupPath & "pra.xml")

Dim Query = From el In xmlDoc.<Root>.<TaskHeaders>
Select el.Elements

For Each el In Query(0)
lstHeaders.Add(el.Value.ToString, el.Attribute("Owner").Value)
Next
TaskHeaders = lstHeaders
Catch ex As ApplicationException
Throw
End Try

End Sub

I have tried searching for the proper syntax but i am noob. Any help would be much appreciated.

View the full article
 
Back
Top