Thanks Noobie

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of .net noobie
Sent: Friday, 12 November 2010 5:57 PM
To: ozDotNet
Subject: Re: xml query

 

I think you want do something like this....

 

 

Dim doc As XElement = <XML> 

<Header> 

<From> 

<Credential domain="Name"> 

<Identity>Hello Australia Limited</Identity> 

</Credential> 

<Credential domain="N"> 

<Identity>320</Identity> 

</Credential> 

<Credential domain="BranchID"> 

<Identity>6043</Identity> 

</Credential> 

<Credential domain="BranchName"> 

<Identity>CENTRE</Identity> 

</Credential> 

<Credential domain="BranchEmail"> 

<Identity>m...@ss.com.au</Identity> 

</Credential> 

</From> 

</Header> 

</XML> 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click 

Dim result As String = (From c In doc...<Credential> Where
c.Attribute("domain").Value = "BranchID" Select
c.<Identity>.Value).FirstOrDefault() 

MsgBox(result)

End Sub 

 

 

On Fri, Nov 12, 2010 at 4:59 PM, Anthony <asale...@tpg.com.au> wrote:

> 

> How do i use linq to select an elementbased on an attribute in a repeating
section?

> 

> This works
Linq.XElement.Parse(sXML).<Header>.<From>.<Credential[3]>.Identity but
assumes its the 3rd one!  Can i select  where domain="BranchID" 

> 

> <XML>

> 

>         <Header>

> 

>                 <From>

> 

>                         <Credential domain="Name">

> 

>                                 <Identity>Hello Australia
Limited</Identity>

> 

>                         </Credential>

> 

>                         <Credential domain="N">

> 

>                                 <Identity>320</Identity>

> 

>                         </Credential>

> 

>                         <Credential domain="BranchID">

> 

>                                 <Identity>6043</Identity>

> 

>                         </Credential>

> 

>                         <Credential domain="BranchName">

> 

>                                 <Identity>CENTRE</Identity>

> 

>                         </Credential>

> 

>                         <Credential domain="BranchEmail">

> 

>                                 <Identity>m...@ss.com.au</Identity>

> 

>                         </Credential>

> 

> Thanks in advance J

> 

> Is your website being IntelliXperienced?  | www.yougoingmyway.com ?

> regards

> Anthony (*12QWERNB*)

> 

> Is your website being IntelliXperienced?

> 

>  

 

Reply via email to