Implement XML data support

Example:

```
{{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }}
    {{ range .channel.item }}
        <strong>{{ .title | plainify | htmlUnescape }}</strong><br />
        <p>{{ .description | plainify | htmlUnescape }}</p>
        {{ $link := .link | plainify | htmlUnescape }}
        <a href="{{ $link }}">{{ $link }}</a><br />
        <hr>
    {{ end }}
{{ end }}
```

Closes #4470
This commit is contained in:
Paul van Brouwershaven
2021-12-02 17:30:36 +01:00
committed by GitHub
parent 58adbeef88
commit 0eaaa8fee3
12 changed files with 167 additions and 12 deletions

View File

@@ -30,6 +30,7 @@ func TestFormatFromString(t *testing.T) {
{"json", JSON},
{"yaml", YAML},
{"yml", YAML},
{"xml", XML},
{"toml", TOML},
{"config.toml", TOML},
{"tOMl", TOML},
@@ -48,6 +49,7 @@ func TestFormatFromMediaType(t *testing.T) {
}{
{media.JSONType, JSON},
{media.YAMLType, YAML},
{media.XMLType, XML},
{media.TOMLType, TOML},
{media.CalendarType, ""},
} {
@@ -70,6 +72,7 @@ func TestFormatFromContentString(t *testing.T) {
{`foo:"bar"`, YAML},
{`{ "foo": "bar"`, JSON},
{`a,b,c"`, CSV},
{`<foo>bar</foo>"`, XML},
{`asdfasdf`, Format("")},
{``, Format("")},
} {