A simple dynamic library implemented in C# 4.0 to deal with XML structure

时间:2019-10-24
本文章向大家介绍A simple dynamic library implemented in C# 4.0 to deal with XML structure,主要包括A simple dynamic library implemented in C# 4.0 to deal with XML structure使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
https://github.com/cardinals/XmlToObjectParser

A simple dynamic library implemented in C# 4.0 to deal with XML structure Assume the following XML sample: _sampleXml = @"<?xml version=""1.0"" encoding=""ISO-8859-1""?> <catalog> <cd country=""USA""> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <price>10.90</price> </cd> <cd country=""UK""> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price>10.0</price> </cd> <cd country=""USA""> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <price>9.90</price> </cd> </catalog>"; With XmlToObjectParser is possible to traversal this XML like this: var numberOfCDsinCatalog = catalog.catalog.cd.Count; //Results in the number Three var titleFromUKCD = catalog.catalog.cd[1].title; // "Hide your heart" For more details take a look at the documentation on the Wiki: https://github.com/tucaz/XmlToObjectParser/wiki/Getting-Started *Special thanks to @MemphisBR for reviewing the code

原文地址:https://www.cnblogs.com/Jeely/p/11731846.html