Skip to content
Extension for Flurl.Http to support XML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
build
src/Flurl.Http.Xml
test/Flurl.Http.Xml.Tests
.gitattributes
.gitignore
Flurl.Http.Xml.sln
LICENSE
NuGet.Config
README.md
appveyor.yml
codecov.yml
global.json

README.md

Icon

Flurl.Http.Xml

Build status license NuGet Coverage Status codecov Dependency Status Join the chat at https://gitter.im/lvermeulen/Flurl.Http.Xml

XML extension to the excellent Flurl library

Features:

  • Get, post and receive XML models
  • Receive XDocument
  • Receive XElements with XPath

Usage:

  • Get an XDocument:
    var result = await "https://query.yahooapis.com/v1/public/yql"
        .SetQueryParam("q", "select wind from weather.forecast where woeid=2460286")
        .SetQueryParam("format", "xml")
        .GetXDocumentAsync();

    string chill = result
        ?.Element("query")
        ?.Element("results")
        ?.Element("channel")
        ?.Element(XNamespace.Get("http://xml.weather.yahoo.com/ns/rss/1.0") + "wind")
        ?.Attribute("chill")
        ?.Value;
  • Post and receive a model:
    var result = await "http://my_xml_endpoint"
        .PostXmlAsync(new TestModel { Number = 3, Text = "Test" })
        .ReceiveXml<TestModel>();

    Assert.AreEqual(3, result.Number);
    Assert.AreEqual("Test", result.Text);
  • Put a model and receive an XDocument:
    var result = await "http://my_xml_endpoint"
        .PutXmlAsync(new TestModel {Number = 3, Text = "Test"})
        .ReceiveXDocument();

    Assert.AreEqual("3", result?.Element("TestModel")?.Element("Number")?.Value);
    Assert.AreEqual("Test", result?.Element("TestModel")?.Element("Text")?.Value);

Thanks

You can’t perform that action at this time.