Tenza
Tenza

Reputation: 2401

LINQ to XML to create complex XML File

I would like to know if there is any simple/fast way to create a complex XML file, when I say complex, I mean more than 20 elements encapsulated. Although this is VB.net, unfortunately literals will not work in this case. Some advice will be most certainly appreciated.

Upvotes: 2

Views: 2281

Answers (2)

Patrick Karcher
Patrick Karcher

Reputation: 23603

You definitely want to System.Xml.Linq tools from .Net 3.5. Even if you aren't using Linq at all, and not using XML literals, it's still a fantastic library for dynamically building XML in code. But since you say you can't use XML literals, does that mean you're in a .Net 3.0 or before project, and you can't upgrade? That would be very unfortunate, to not be able to use the best tooling.

Assuming you can use System.Xml.Linq, and you just have a silly boss who is against the XML literals syntactic sugar (some sort of language snob perhaps?), then you need to get familiar with the library, centered around the XElement class.

I would strongly suggest watching the following video casts on dnrtv, Part1 and Part2.

Upvotes: 2

Pranay Rana
Pranay Rana

Reputation: 176896

XLinq: Create XML from object using LINQ

To play with the XML data if you are using .net version 3.5 its better to user LINQ to XML.

http://www.codeproject.com/Articles/24376/LINQ-to-XML

or

Manipulate XML data with XPath and XmlDocument (C#)

Upvotes: 2

Related Questions