xdocument

How to preserve whitespaces in attributes values when using XDocument?

I process xml which contains tabs ("\t") and line breaks ("\n") in its attributes values. When I parse it using XDocument.Parse(), the tabs and line breaks are converted to spaces, even with the LoadOptions.PreserveWhitespace parameter. How can I get a XDocument with original attributes values? ...

read attribute using XDocument and LINQ

Hi, I'm trying to parse a rss feed. I can get the elements out, but whatever i try, i cant get the attributes! This is how the rss feed (xml) looks like: <?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>nu.nl - Algemeen</title> <copyright>Copyright (c) 2010, nu.nl</copyright> <link>http://www....

XDocument: Conditionally create new XElement...

Hi all, My question is regarding conditionally creation of XElements, that is, if some condition is met, create the XElement, if not, skip creating the XElement? At this point of time, I could create empty XElements, and then remove all empty elements, by checking, if IsEmpty is true, but that somehow does not feel right... I feel, tha...

Load xml file from website into XDocument (silverlight and WP7)

Hi, I have an xml file that I want to access in an WP7 and Silverlight app. Th exml file is on a webserver and I want to access is through http://www.mydomain.com/data/this_is_my_file.xml. So I want to use this url to load the xml file into an XDocument; Any ideas, thanks, Filip ...

How can I parse the information from this XML?

Hi guys, this is an example of the XML I want to scrape: http://www.dreamincode.net/forums/xml.php?showuser=335389 Notice that the contactinformation tag has many contact elements, each similar but with different values. For example, the element that has the AIM content in it, how can I get the content of the Value tag that's in the s...

How to loop through a set of XElements?

http://www.dreamincode.net/forums/xml.php?showuser=335389 Given the XML above, how can I iterate through each element inside of the 'lastvisitors' element, given that each child group is the same with just different values? //Load latest visitors. var visitorXML = xml.Element("ipb").Element("profile").Element("latestvisitors"); So no...

Trouble assigning a value to this variable.

Using this code I intend to populate the variables. http://www.dreamincode.net/forums/xml.php?showuser=146038 //Load comments. var commentsXML = xml.Element("ipb").Element("profile").Element("comments"); this.Comments = (from comment in commentsXML.Descendants("comment") select new Comment() { ...

NullReferenceException on this C# code.

Here is the entire code for my class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Xml.Linq; namespace SharpDIC.Entities { /// <summary> /// Represents a forum on the Dream.In.Code website. /// </summary> public class Forum { //Forum inf...

DataContract XSD issue

I am wanting to validate a DataContract (long story short) Here is my DataContract: [DataContract(Name = User.Root, Namespace = "http://mysoft.com/schemas/registeruser.xsd")] public class RegisterUser { [DataMember(Name = User.EmailAddress)] public string EmailAddress { get; set; } [DataMember(Name = User.UserName)]...