TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Daniel Golan
NA
45
47.6k
Read xml error
Dec 19 2010 6:40 AM
Hello, working on a code to read xml, got a hint that i cant use xdocument since not valid characters in the xml.
The purpose of the code is to use the value from he cmblist to find a specifific node and print it in a txt box. Would be very happy for any help :)
The xml :
http://www.yr.no/sted/Norge/Akershus/Nesodden/Fjellstrand/varsel.xml
The code
XDocument
xmlDoc =
XDocument
.Load(
"C:/Users/Daxal/documents/visual studio 2010/Projects/Yr/Yr/fjellstrand.xml"
);
var
games =
from
game
in
xmlDoc.Descendants(
"weatherdata"
)
where
game.Element(
"forecast"
).Element(
"text"
).Element(
"location"
).Element(
"time"
).Attribute(
"from"
).Value == cmb_sted.SelectedItem.ToString()
select
new
{
Title = game.Element(
"title"
).Value,
Body = game.Element(
"body"
).Value,
};
txt_result.Text =
""
;
foreach
(
var
game
in
games)
{
//write values in txt box
txt_result.Text = txt_result.Text +
"Title : "
+ game.Title +
"\n"
;
txt_result.Text = txt_result.Text +
"Body : "
+ game.Body +
"\n\n"
;
}
if
(txt_result.Text ==
""
)
txt_result.Text =
"No Results."
;
Reply
Answers (
6
)
Xml Attributes
insert via Linq is not working