EDN Admin
Well-known member
<div style="color:Black;background-color:White; <pre>
Im new to LINQ to XML and I have the following XML structure.
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; pre <span style="color:Red; lang<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; x-xml<span style="color:Black; "<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test.YEAR<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_one<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_one.MONTH<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_two<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; FUNC<span style="color:Black; " <span style="color:Red; func<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; AVG<span style="color:Black; " <span style="color:Red; distinct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; False<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; argument <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_two.DAY<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; expr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
[/code]
<div style="color:Black;background-color:White; <pre>
Im able to get the value from the "id" attribute of the <span style="color:Blue; <<span style="color:#A31515; expr<span style="color:Blue; > tag fine using:
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; pre <span style="color:Red; lang<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; x-vbnet<span style="color:Black; "<span style="color:Blue; >Dim qList = From c In document.Descendants("Column") Select c.Element("expr")
Populate DropDownList with expressions
For Each item In qList.ToList
Dim node As String = String.Empty
node = item.Attribute("id").Value
ddlCriteria.Items.Add(New ListItem(node, node))
Next
[/code]
<div style="color:Black;background-color:White; <pre>
I<span style="color:Green; m just not sure how to get the value from the "id" attribute of the <argument> tag.
[/code]
<div style="color:Black;background-color:White; <pre>
<pre lang=<span style="color:#A31515; "x-xml"><span style="color:Blue; For <span style="color:Blue; Each item <span style="color:Blue; In qList.ToList
<span style="color:Blue; Dim node <span style="color:Blue; As <span style="color:Blue; String = <span style="color:Blue; String.Empty
<span style="color:Blue; If item.Attribute(<span style="color:#A31515; "class").Value = <span style="color:#A31515; "FUNC" <span style="color:Blue; Then
<span style="color:Green; get id of <argument> here?
[/code]
<div style="color:Black;background-color:White; <pre>
node = ????
[/code]
<div style="color:Black;background-color:White; <pre>
Else
node = Right(item.Attribute("id").Value, Len(item.Attribute("id").Value) - 2)
End If
ddlCriteria.Items.Add(New ListItem(node, node))
Next
[/code]
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Any help <span style="color:Blue; or suggestions would be appreciated. Thanks
[/code]
<div style="color:Black;background-color:White; <pre>
Andy
[/code]
[/code]
[/code]
View the full article
Im new to LINQ to XML and I have the following XML structure.
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; pre <span style="color:Red; lang<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; x-xml<span style="color:Black; "<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test.YEAR<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_one<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_one.MONTH<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Column <span style="color:Red; caption<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_two<span style="color:Black; " <span style="color:Red; sorting<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; None<span style="color:Black; " <span style="color:Red; sortindex<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; expr <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; FUNC<span style="color:Black; " <span style="color:Red; func<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; AVG<span style="color:Black; " <span style="color:Red; distinct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; False<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; argument <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATTR<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; test_two.DAY<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; expr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Column<span style="color:Blue; >
[/code]
<div style="color:Black;background-color:White; <pre>
Im able to get the value from the "id" attribute of the <span style="color:Blue; <<span style="color:#A31515; expr<span style="color:Blue; > tag fine using:
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; pre <span style="color:Red; lang<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; x-vbnet<span style="color:Black; "<span style="color:Blue; >Dim qList = From c In document.Descendants("Column") Select c.Element("expr")
Populate DropDownList with expressions
For Each item In qList.ToList
Dim node As String = String.Empty
node = item.Attribute("id").Value
ddlCriteria.Items.Add(New ListItem(node, node))
Next
[/code]
<div style="color:Black;background-color:White; <pre>
I<span style="color:Green; m just not sure how to get the value from the "id" attribute of the <argument> tag.
[/code]
<div style="color:Black;background-color:White; <pre>
<pre lang=<span style="color:#A31515; "x-xml"><span style="color:Blue; For <span style="color:Blue; Each item <span style="color:Blue; In qList.ToList
<span style="color:Blue; Dim node <span style="color:Blue; As <span style="color:Blue; String = <span style="color:Blue; String.Empty
<span style="color:Blue; If item.Attribute(<span style="color:#A31515; "class").Value = <span style="color:#A31515; "FUNC" <span style="color:Blue; Then
<span style="color:Green; get id of <argument> here?
[/code]
<div style="color:Black;background-color:White; <pre>
node = ????
[/code]
<div style="color:Black;background-color:White; <pre>
Else
node = Right(item.Attribute("id").Value, Len(item.Attribute("id").Value) - 2)
End If
ddlCriteria.Items.Add(New ListItem(node, node))
Next
[/code]
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Any help <span style="color:Blue; or suggestions would be appreciated. Thanks
[/code]
<div style="color:Black;background-color:White; <pre>
Andy
[/code]
[/code]
[/code]
View the full article