Skip to content

lvermeulen/Flurl.Http.Xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

443a14c · Jan 6, 2024
Jun 2, 2016
Jul 4, 2020
Jan 6, 2024
Jan 6, 2024
Oct 16, 2019
Jul 11, 2016
Jul 11, 2016
Jan 6, 2024
May 21, 2016
Jul 18, 2016
Nov 2, 2020
Jan 6, 2024
Jan 6, 2024

Repository files navigation

Icon

Flurl.Http.Xml

Build status license NuGet downloads

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