Dandraka.XmlUtilities
1.1.0
Version 1.1 has many bugs when parsing complex xml; these have been solved in versions >= 1.2. Versions 1.2.x are completely backwards compatible with 1.0 & 1.1, so it's highly recommended to upgrade.
See the version list below for details.
dotnet add package Dandraka.XmlUtilities --version 1.1.0
NuGet\Install-Package Dandraka.XmlUtilities -Version 1.1.0
<PackageReference Include="Dandraka.XmlUtilities" Version="1.1.0" />
paket add Dandraka.XmlUtilities --version 1.1.0
#r "nuget: Dandraka.XmlUtilities, 1.1.0"
// Install Dandraka.XmlUtilities as a Cake Addin #addin nuget:?package=Dandraka.XmlUtilities&version=1.1.0 // Install Dandraka.XmlUtilities as a Cake Tool #tool nuget:?package=Dandraka.XmlUtilities&version=1.1.0
XmlUtilities
An XmlSlurper implementation for .Net. The idea came from Groovy's XmlSlurper which is hugely useful.
What this does, is convert a piece of xml, e.g.
<card xmlns="http://businesscard.org">
<name>John Doe</name>
<title>CEO, Widget Inc.</title>
<email>john.doe@widget.com</email>
<phone>(202) 456-1414</phone>
<logo url="widget.gif"/>
</card>
to a C# object, e.g.
card.name
card.title
card.email
card.phone
card.logo.url
This is done without any need to declare the type (it actually uses System.Dynamic.ExpandoObject behind the scenes).
Under the Release tab you can find the binaries to download.
Usage:
using Dandraka.XmlUtilities;
public void PrintXmlContents1()
{
string xml = "<book id=\"bk101\" isbn=\"123456789\"><author>Gambardella, Matthew</author><title>XML Developer Guide</title></book>";
var book = XmlSlurper.ParseText(xml);
// that's it, now we have everything
Console.WriteLine("id = " + book.id);
Console.WriteLine("isbn = " + book.isbn);
Console.WriteLine("author = " + book.author);
Console.WriteLine("title = " + book.title);
}
public void PrintXmlContents2()
{
string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<nutrition>" +
" <food>" +
" <name>Avocado Dip</name>" +
" <mfr>Sunnydale</mfr>" +
" <carb>2</carb>" +
" <fiber>0</fiber>" +
" <protein>1</protein>" +
" </food>" +
" <food>" +
" <name>Bagels, New York Style </name>" +
" <mfr>Thompson</mfr>" +
" <carb>54</carb>" +
" <fiber>3</fiber>" +
" <protein>11</protein>" +
" </food>" +
" <food>" +
" <name>Beef Frankfurter, Quarter Pound </name>" +
" <mfr>Armitage</mfr>" +
" <carb>8</carb>" +
" <fiber>0</fiber>" +
" <protein>13</protein>" +
" </food>" +
"</nutrition>";
var nutrition = XmlSlurper.ParseText(xml);
// since many food nodes were found, a list was generated and named foodList (common name + "List")
Console.WriteLine("name1 = " + nutrition.foodList[0].name);
Console.WriteLine("name2 = " + nutrition.foodList[1].name);
}
Releases:
The first production-ready release was uploaded. Please see the release page for a known bug.
Note:
Although not required by the license, the author kindly asks that you share any improvements you made.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release 1.1 was converted from .Net Framework to .Net Standard (and tests to .Net core), in order to be as portable as possible.