简体   繁体   中英

Generate LINQ to XML C# code, from an XML document?

Does anybody know of a tool that will generate LINQ to XML code from a real XML document or fragment? It's reverse-engineering the common scenario of generating XML.

For example, I want to provide an XML fragment as input like this

<root>
    <thing>value</thing>
</root>

and have it generate the equivalent C# LINQ to XML code snippet like so

var x = new XElement("root",
    new XElement("thing", new XText("value"));
    );

Although I'm looking for a quickie, I'm sure some enterprising individuals will tell me to roll my own and provide some awesome reference code.

See this tool.

the application supports :

  • XDocument
  • XDeclaration
  • XProcessingInstruction
  • XComment
  • XNamespace
  • XElement
  • XAttribute

  • generation of business objects

  • generation of code Linq To Xml (with variables, in method, extraction of the code corresponding to the selected nodes)

  • you can open a Xml file or directly copy to stick xml in the richtextbox

  • the editor allows to create Xml documents from scratch or to add/modify existing Xml documents
  • the editor has several views which are synchronized (Text, treeview)
  • a help with the seizure (auto completion tags and attributes and checking in the course of the good formation of xml) for the text view,…
  • you can also post the data of the nodes selected in a datagridview
  • etc

这对于使用T4模板或XSL转换来说并不难,但我不知道有谁做过它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM