Skip to content

Releases: rmkane/go-xpath-utils

Release list

v0.1.0

Choose a tag to compare

@rmkane rmkane released this 27 Feb 15:07

The main package has been changed from xpath to xpathutils.

Added

Attributes can now be retrieved via XPath:

value, err := xpathutils.GetAttrByXPathFromFile(inputFile, expr)
value, err := xpathutils.GetAttrByXPathFromString(xmlStr, expr)

Updated

  • Adding an attribute no longer requires specifying the key. It is now extracted from the XPath expression.

    err := xpathutils.AddAttrByXPathFromFile(inputFile, outputFile, expr, value)
    updatedXML, err := xpathutils.AddAttrByXPathFromString(xmlStr, expr, value)
  • Updating an attribute is now restricted to attributes only.

    err := xpathutils.UpdateAttrByXPathFromFile("foo.xml", outputFile, expr, value)
    updatedXML, err := xpathutils.UpdateAttrByXPathFromString(xmlStr, expr, value)
  • Separated attribute and node removal logic for clarity.

    err := xpathutils.RemoveAttrByXPathFromFile("foo.xml", outputFile, expr)
    updatedXML, err := xpathutils.RemoveAttrByXPathFromString(xmlStr, expr)
    
    err := xpathutils.RemoveNodeByXPathFromFile("foo.xml", outputFile, expr)
    updatedXML, err := xpathutils.RemoveNodeByXPathFromString(xmlStr, expr)

v0.0.1

v0.0.1 Pre-release
Pre-release

Choose a tag to compare

@rmkane rmkane released this 26 Feb 20:44

This is the initial release.

Features

The following functions should be available:

Update XML file:

err := xpath.AddByXPathFromFile(inputFile, outputFile, exrp, key, value)
err := xpath.UpdateByXPathFromFile(inputFile, outputFile, exrp, value)
err := xpath.RemoveByXPathFromFile(inputFile, outputFile, exrp)

Update XML string:

updatedXML, err := xpath.AddByXPathFromString(xmlStr, exrp, key, value)
updatedXML, err := xpath.UpdateByXPathFromString(xmlStr, exrp, value)
updatedXML, err := xpath.RemoveByXPathFromString(xmlStr, exrp)