EDN Admin
Well-known member
I want to select an attribut value, only if the attribute before it, is equal to a certain value.
I am able to get all of the info by using a lambda and selecting an array...but I dont want an array...just need the single value.
in the xml snip it below, there are 3 "home-score" elements and 3 "visiting-score" elements for each team.
I need the "number" attribute for the runs, hits, errors.
I made a variable called test in the query, but it seems to want me to make it an array or something else like list..I just want a single value...
xml snipit and code below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; UTF-8<span style="color:Black; " <span style="color:Blue; ?>
- <span style="color:Blue; <<span style="color:#A31515; sports-statistics<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; sports-scores<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 14<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 57<span style="color:Black; " <span style="color:Red; second<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 46<span style="color:Black; " <span style="color:Red; timezone<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eastern<span style="color:Black; " <span style="color:Red; utc-hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -4<span style="color:Black; " <span style="color:Red; utc-minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; version <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; season <span style="color:Red; season<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; baseball-mlb-scores<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; baseball-mlb-score<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 13<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 05<span style="color:Black; " <span style="color:Red; timezone<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eastern<span style="color:Black; " <span style="color:Red; utc-hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -4<span style="color:Black; " <span style="color:Red; utc-minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; local-game-date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; local-time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 13<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 05<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gamecode <span style="color:Red; code<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 310331120<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1023893<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gametype <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Regular Season<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; league <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; league<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; NL<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; double-header <span style="color:Red; double-header<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; false<span style="color:Black; " <span style="color:Red; double-header-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; double-header-game-number <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; stadium <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Nationals Park<span style="color:Black; " <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Washington<span style="color:Black; " <span style="color:Red; state<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; District of Columbia<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 89<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6423<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gamestate <span style="color:Red; status<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; In-Progress<span style="color:Black; " <span style="color:Red; status-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; reason<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; " inning="Top of 7<span style="color:Black; " <span style="color:Red; balls<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; strikes<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; outs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; segment-number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7<span style="color:Black; " <span style="color:Red; segment-division<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Top<span style="color:Black; " <span style="color:Red; active-state<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Red; active-state-id<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; current-batter <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6077<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8220<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Alex<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Gonzalez<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; runners-on-base<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first-base <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8621<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 388409<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Jason<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Heyward<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; second-base <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7692<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 200339<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Dan<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Uggla<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; runners-on-base<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; visiting-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; team-name <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Braves<span style="color:Black; " <span style="color:Red; alias<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Atl<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-city <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Atlanta<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-code <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 15<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 239<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; record <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; ties<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; pct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; score<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; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; score<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; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 5<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; current-pitcher <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7837<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244012<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eric<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; OFlaherty<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Freddie<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Freeman<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8658<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 390291<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-two <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eric<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; OFlaherty<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7837<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244012<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-three <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Martin<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Prado<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7737<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244153<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; due-up <span style="color:Red; due<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; visiting-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; runs<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; hits<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; errors<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; home-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; team-name <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Nationals<span style="color:Black; " <span style="color:Red; alias<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Was<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-city <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Washington<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-code <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 20<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; record <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; ties<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; pct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 5<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; current-pitcher <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7970<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244022<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Tyler<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Clippard<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Rick<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Ankiel<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6320<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8453<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-two <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Danny<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Espinosa<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8805<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 454456<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; S<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-three <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Ivan<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Rodriguez<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4680<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6853<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; due-up <span style="color:Red; due<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; home-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; runs<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; hits<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; errors<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; baseball-mlb-score<span style="color:Blue; >
[/code]
code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; var query =<span style="color:Blue; from feed <span style="color:Blue; in xmlfeed.Descendants(<span style="color:#A31515; "baseball-mlb-score")
<span style="color:Blue; select <span style="color:Blue; new
{
eventID = feed.Element(<span style="color:#A31515; "gamecode").Attribute(<span style="color:#A31515; "code").Value,
curPeriod = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "segment-number").Value,
inningInfo = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "inning").Value,
status = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "status").Value,
vname = feed.Element(<span style="color:#A31515; "visiting-team").Element(<span style="color:#A31515; "team-name").Attribute(<span style="color:#A31515; "name").Value.ToUpper(),
<span style="color:Green; //vscore = feed.Element("visiting-team").Elements("visiting-score")
vscore = feed.Elements(<span style="color:#A31515; "visiting-score")
.Select(w => <span style="color:Blue; new
{
vtype = w.Attribute(<span style="color:#A31515; "type").Value,
vnumber = w.Attribute(<span style="color:#A31515; "number").Value
}).ToArray(),
hname = feed.Element(<span style="color:#A31515; "home-team").Element(<span style="color:#A31515; "team-name").Attribute(<span style="color:#A31515; "name").Value.ToUpper(),
test = feed.Elements(<span style="color:#A31515; "home-score")
.Where(w => w.Attribute(<span style="color:#A31515; "type").Value == <span style="color:#A31515; "runs")
.Select(w => <span style="color:Blue; new {runs = w.Attribute(<span style="color:#A31515; "number")}).ToArray(),
<span style="color:Green; //hscore = feed.Element("home-team").Elements("home-score")
hscore = feed.Elements(<span style="color:#A31515; "home-score")
.Select(w => <span style="color:Blue; new
{
htype = w.Attribute(<span style="color:#A31515; "type").Value,
hnumber = w.Attribute(<span style="color:#A31515; "number").Value
}).ToArray(),
};
[/code]
View the full article
I am able to get all of the info by using a lambda and selecting an array...but I dont want an array...just need the single value.
in the xml snip it below, there are 3 "home-score" elements and 3 "visiting-score" elements for each team.
I need the "number" attribute for the runs, hits, errors.
I made a variable called test in the query, but it seems to want me to make it an array or something else like list..I just want a single value...
xml snipit and code below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; UTF-8<span style="color:Black; " <span style="color:Blue; ?>
- <span style="color:Blue; <<span style="color:#A31515; sports-statistics<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; sports-scores<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 14<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 57<span style="color:Black; " <span style="color:Red; second<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 46<span style="color:Black; " <span style="color:Red; timezone<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eastern<span style="color:Black; " <span style="color:Red; utc-hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -4<span style="color:Black; " <span style="color:Red; utc-minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; version <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; season <span style="color:Red; season<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; baseball-mlb-scores<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; baseball-mlb-score<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 13<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 05<span style="color:Black; " <span style="color:Red; timezone<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eastern<span style="color:Black; " <span style="color:Red; utc-hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -4<span style="color:Black; " <span style="color:Red; utc-minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; local-game-date <span style="color:Red; year<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011<span style="color:Black; " <span style="color:Red; month<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; date<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 31<span style="color:Black; " <span style="color:Red; day<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; local-time <span style="color:Red; hour<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 13<span style="color:Black; " <span style="color:Red; minute<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 05<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gamecode <span style="color:Red; code<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 310331120<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1023893<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gametype <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Regular Season<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; league <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; league<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; NL<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; double-header <span style="color:Red; double-header<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; false<span style="color:Black; " <span style="color:Red; double-header-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; double-header-game-number <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; stadium <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Nationals Park<span style="color:Black; " <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Washington<span style="color:Black; " <span style="color:Red; state<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; District of Columbia<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 89<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6423<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; gamestate <span style="color:Red; status<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; In-Progress<span style="color:Black; " <span style="color:Red; status-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; reason<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; " inning="Top of 7<span style="color:Black; " <span style="color:Red; balls<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; strikes<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; outs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; segment-number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7<span style="color:Black; " <span style="color:Red; segment-division<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Top<span style="color:Black; " <span style="color:Red; active-state<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Red; active-state-id<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; current-batter <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6077<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8220<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Alex<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Gonzalez<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; runners-on-base<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first-base <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8621<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 388409<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Jason<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Heyward<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; second-base <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7692<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 200339<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Dan<span style="color:Black; " <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Uggla<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; runners-on-base<span style="color:Blue; >
- <span style="color:Blue; <<span style="color:#A31515; visiting-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; team-name <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Braves<span style="color:Black; " <span style="color:Red; alias<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Atl<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-city <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Atlanta<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-code <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 15<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 239<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; record <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; ties<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; pct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; score<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; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; score<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; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 5<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; current-pitcher <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7837<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244012<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eric<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; OFlaherty<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Freddie<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Freeman<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8658<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 390291<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-two <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Eric<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; OFlaherty<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7837<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244012<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-three <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Martin<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Prado<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7737<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244153<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; due-up <span style="color:Red; due<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; visiting-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; runs<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; hits<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; visiting-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; errors<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; home-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; team-name <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Nationals<span style="color:Black; " <span style="color:Red; alias<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Was<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-city <span style="color:Red; city<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Washington<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; team-code <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 20<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; record <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; ties<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; pct<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; -<span style="color:Black; " <span style="color:Blue; />
- <span style="color:Blue; <<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 5<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; inning <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6<span style="color:Black; " <span style="color:Red; score<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; innings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; current-pitcher <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 7970<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 244022<span style="color:Black; " <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Tyler<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Clippard<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Red; wins<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; losses<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Rick<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Ankiel<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6320<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8453<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-two <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Danny<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Espinosa<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 8805<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 454456<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; S<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; next-up-batter-three <span style="color:Red; first-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Ivan<span style="color:Black; " <span style="color:Red; last-name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Rodriguez<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4680<span style="color:Black; " <span style="color:Red; global-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 6853<span style="color:Black; " <span style="color:Red; hand<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; R<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; due-up <span style="color:Red; due<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; home-team<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; runs<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; hits<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 4<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; home-score <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; errors<span style="color:Black; " <span style="color:Red; type-id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; " <span style="color:Red; number<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; baseball-mlb-score<span style="color:Blue; >
[/code]
code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; var query =<span style="color:Blue; from feed <span style="color:Blue; in xmlfeed.Descendants(<span style="color:#A31515; "baseball-mlb-score")
<span style="color:Blue; select <span style="color:Blue; new
{
eventID = feed.Element(<span style="color:#A31515; "gamecode").Attribute(<span style="color:#A31515; "code").Value,
curPeriod = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "segment-number").Value,
inningInfo = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "inning").Value,
status = feed.Element(<span style="color:#A31515; "gamestate").Attribute(<span style="color:#A31515; "status").Value,
vname = feed.Element(<span style="color:#A31515; "visiting-team").Element(<span style="color:#A31515; "team-name").Attribute(<span style="color:#A31515; "name").Value.ToUpper(),
<span style="color:Green; //vscore = feed.Element("visiting-team").Elements("visiting-score")
vscore = feed.Elements(<span style="color:#A31515; "visiting-score")
.Select(w => <span style="color:Blue; new
{
vtype = w.Attribute(<span style="color:#A31515; "type").Value,
vnumber = w.Attribute(<span style="color:#A31515; "number").Value
}).ToArray(),
hname = feed.Element(<span style="color:#A31515; "home-team").Element(<span style="color:#A31515; "team-name").Attribute(<span style="color:#A31515; "name").Value.ToUpper(),
test = feed.Elements(<span style="color:#A31515; "home-score")
.Where(w => w.Attribute(<span style="color:#A31515; "type").Value == <span style="color:#A31515; "runs")
.Select(w => <span style="color:Blue; new {runs = w.Attribute(<span style="color:#A31515; "number")}).ToArray(),
<span style="color:Green; //hscore = feed.Element("home-team").Elements("home-score")
hscore = feed.Elements(<span style="color:#A31515; "home-score")
.Select(w => <span style="color:Blue; new
{
htype = w.Attribute(<span style="color:#A31515; "type").Value,
hnumber = w.Attribute(<span style="color:#A31515; "number").Value
}).ToArray(),
};
[/code]
View the full article