EDN Admin
Well-known member
I have an XML document with a structure similer to the following:
<div style="color:black; background-color:white
<pre><span style="color:blue <<span style="color:#a31515 Properties<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Property<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 ID<span style="color:blue >-26579190<span style="color:blue </<span style="color:#a31515 ID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 EntityID<span style="color:blue >1501329<span style="color:blue </<span style="color:#a31515 EntityID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Cntc_ID<span style="color:blue >0<span style="color:blue </<span style="color:#a31515 Cntc_ID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Firm_Name<span style="color:blue >Joes Law Firm<span style="color:blue </<span style="color:#a31515 Firm_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Last_Name<span style="color:blue >Blow<span style="color:blue </<span style="color:#a31515 Last_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Frst_Name<span style="color:blue >Joe<span style="color:blue </<span style="color:#a31515 Frst_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Titl<span style="color:blue >Titl7<span style="color:blue </<span style="color:#a31515 Titl<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Addr1<span style="color:blue >Addr17<span style="color:blue </<span style="color:#a31515 Addr1<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Addr2<span style="color:blue >Addr27<span style="color:blue </<span style="color:#a31515 Addr2<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 City<span style="color:blue >City7<span style="color:blue </<span style="color:#a31515 City<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 St<span style="color:blue >CA<span style="color:blue </<span style="color:#a31515 St<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Zip<span style="color:blue >Zip7<span style="color:blue </<span style="color:#a31515 Zip<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Zip_Ext<span style="color:blue >777<span style="color:blue </<span style="color:#a31515 Zip_Ext<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Phon<span style="color:blue >PhoneNumber7<span style="color:blue </<span style="color:#a31515 Phon<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Phon_Ext<span style="color:blue >Phone<span style="color:blue </<span style="color:#a31515 Phon_Ext<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 Property<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 Properties<span style="color:blue >
[/code]
I am able to get the value of a single element doing something like this:
<div style="color:black; background-color:white
<pre><span style="color:blue var attorneyid = (<span style="color:blue from p <span style="color:blue in attorney.Descendants(<span style="color:#a31515 "ID") <span style="color:blue select <span style="color:blue new { Value = p.Value }).SingleOrDefault();
[/code]
I can now access the value with a simple
<div style="color:black; background-color:white
<pre><span style="color:blue var id = attorneyid.Value;
[/code]
I would like to be able to access any or all of the element values in the Property node by using a similar construct that will capture them in a single LINQ to XML query, but not sure how to do it.
IOW, I would create an object from the query that can do something like:
<div style="color:black; background-color:white
<pre><span style="color:blue var id = property.AttorneyId;
<span style="color:blue var firm = property.FirmName;
<span style="color:blue var lastname = property.LastName;
[/code]
Is there a simple query that can accomplish this task:<br/>
<br/>
View the full article
<div style="color:black; background-color:white
<pre><span style="color:blue <<span style="color:#a31515 Properties<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Property<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 ID<span style="color:blue >-26579190<span style="color:blue </<span style="color:#a31515 ID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 EntityID<span style="color:blue >1501329<span style="color:blue </<span style="color:#a31515 EntityID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Cntc_ID<span style="color:blue >0<span style="color:blue </<span style="color:#a31515 Cntc_ID<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Firm_Name<span style="color:blue >Joes Law Firm<span style="color:blue </<span style="color:#a31515 Firm_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Last_Name<span style="color:blue >Blow<span style="color:blue </<span style="color:#a31515 Last_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Frst_Name<span style="color:blue >Joe<span style="color:blue </<span style="color:#a31515 Frst_Name<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Titl<span style="color:blue >Titl7<span style="color:blue </<span style="color:#a31515 Titl<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Addr1<span style="color:blue >Addr17<span style="color:blue </<span style="color:#a31515 Addr1<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Addr2<span style="color:blue >Addr27<span style="color:blue </<span style="color:#a31515 Addr2<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 City<span style="color:blue >City7<span style="color:blue </<span style="color:#a31515 City<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 St<span style="color:blue >CA<span style="color:blue </<span style="color:#a31515 St<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Zip<span style="color:blue >Zip7<span style="color:blue </<span style="color:#a31515 Zip<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Zip_Ext<span style="color:blue >777<span style="color:blue </<span style="color:#a31515 Zip_Ext<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Phon<span style="color:blue >PhoneNumber7<span style="color:blue </<span style="color:#a31515 Phon<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 Phon_Ext<span style="color:blue >Phone<span style="color:blue </<span style="color:#a31515 Phon_Ext<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 Property<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 Properties<span style="color:blue >
[/code]
I am able to get the value of a single element doing something like this:
<div style="color:black; background-color:white
<pre><span style="color:blue var attorneyid = (<span style="color:blue from p <span style="color:blue in attorney.Descendants(<span style="color:#a31515 "ID") <span style="color:blue select <span style="color:blue new { Value = p.Value }).SingleOrDefault();
[/code]
I can now access the value with a simple
<div style="color:black; background-color:white
<pre><span style="color:blue var id = attorneyid.Value;
[/code]
I would like to be able to access any or all of the element values in the Property node by using a similar construct that will capture them in a single LINQ to XML query, but not sure how to do it.
IOW, I would create an object from the query that can do something like:
<div style="color:black; background-color:white
<pre><span style="color:blue var id = property.AttorneyId;
<span style="color:blue var firm = property.FirmName;
<span style="color:blue var lastname = property.LastName;
[/code]
Is there a simple query that can accomplish this task:<br/>
<br/>
View the full article