| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A golang implementation of RFC 5261: "An Extensible Markup Language (XML) Patch Operations Framework Utilizing XML Path Language (XPath) Selectors".
This library is still in early stage. API may break. Missing functionality (see progress). Probably buggy 🐛.
go get github.com/jfrog/go-xml-patchpackage main
import (
"fmt"
"github.com/jfrog/go-xml-patch"
"os"
)
func main() {
target, _ := os.ReadFile("target.xml")
diff, _ := os.ReadFile("diff.xml")
patch, err := xmlpatch.Patch(target, diff)
if err != nil {
panic(err)
}
fmt.Println(patch)
}An example target XML document:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<foo a="1">This is a sample document</foo>
</doc>An XML diff document:
<?xml version="1.0" encoding="UTF-8"?>
<diff>
<replace sel="doc/foo[@a='1']">
<bar a="2"/>
</replace>
</diff>A result XML document:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<bar a="2"/>
</doc>(manual for now)
Follow Go module publishing instructions and then create a new Github release.
| Back | FazBrowse Home | New Git URL |