KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
For some reason the following code produces XML that does not contain a declaration: XDocument xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("project", new XAttribute("number", project.ProjectNumber), new XElement("store", new XAttribute("number", project.StoreNumber) ), // User Element new XElement("user", new XAttribute("owner-id", project.OwnerID ?? 0), new XElement("email", new XCData(project.OwnerEmail ?? "")), new XElement("project-name", new XCData(project.ProjectName ?? "")) ), // Nested Project Element new XElement("nested-project", new XAttribute("version", new Version(1, 0)), new XElement("project", new XAttribute("version", new Version(1, 0)), xProjectItems = new XElement("project-items") ), new XElement("price-per-part", project.PricePerPart), new XElement("sheet-quantity", project.SheetQuantity), new XElement("edge-length", project.EdgeLength), new XElement("price", project.Price), new XElement("status", project.Status), xMaterialItems = new XElement("alternative-material-items"), xProductItems = new XElement("project-product-items") ) ) ); String strXML = xDocument.ToString(); It has produced a declaration before. Am I missing something obvious? Thanks.
Tags (comma-separated)
Save Edits
Cancel