Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lvermeulen/flurl.http.xml
Extension for Flurl.Http to support XML
https://github.com/lvermeulen/flurl.http.xml
flurl xdocument xml
Last synced: 3 days ago
JSON representation
Extension for Flurl.Http to support XML
- Host: GitHub
- URL: https://github.com/lvermeulen/flurl.http.xml
- Owner: lvermeulen
- License: mit
- Created: 2016-05-21T09:11:33.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-02-20T11:16:30.000Z (12 months ago)
- Last Synced: 2025-01-21T21:06:04.495Z (11 days ago)
- Topics: flurl, xdocument, xml
- Language: C#
- Size: 190 KB
- Stars: 50
- Watchers: 8
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Icon](http://i.imgur.com/llEKpRL.png?1)
# Flurl.Http.Xml
[![Build status](https://ci.appveyor.com/api/projects/status/16qwl13xsaylb450?svg=true)](https://ci.appveyor.com/project/lvermeulen/flurl-http-xml)
[![license](https://img.shields.io/github/license/lvermeulen/Flurl.Http.Xml.svg?maxAge=2592000)](https://github.com/lvermeulen/Flurl.Http.Xml/blob/master/LICENSE)
[![NuGet](https://img.shields.io/nuget/v/Flurl.Http.Xml.svg?maxAge=86400)](https://www.nuget.org/packages/Flurl.Http.Xml/)
![downloads](https://img.shields.io/nuget/dt/Flurl.Http.Xml)
![](https://img.shields.io/badge/.net-4.6.1-yellowgreen.svg)
![](https://img.shields.io/badge/netstandard-2.0-yellowgreen.svg)XML extension to the excellent [Flurl](https://github.com/tmenier/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();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
* [XML File](https://thenounproject.com/term/xml-file/320630/) icon by [Oliviu Stoian](https://thenounproject.com/smashicons/) from [The Noun Project](https://thenounproject.com)