fxml - FreeStyle XML Parser
This package provides a simple parser which reads a XML document and output a tree structure, which does not need a pre-defined struct
, hence the name "FreeStyle".
See godoc for more information.
This package provides a simple parser which reads a XML document and output a tree structure, which does not need a pre-defined struct
, hence the name "FreeStyle".
See godoc for more information.
exml 🧑‍💻 Go XML generator without Structs™ Package exml allows XML documents to be generated without the usage of structs or maps. It is not intende
wikipedia-jsonl wikipedia-jsonl is a CLI that converts Wikipedia dump XML to JSON Lines format. How to use At first, download the XML dump from Wikime
sqly An easy-to-use extension for sqlx ,base on xml files and named query/exec t
THIS PROJECT IS UNMAINTAINED The last commit to this repo before writing this message occurred over two years ago. While it was never my intention to
User agent parsing useragent is a library written in golang to parse user agent strings. Usage First install the library with: go get xojoc.pw/userage
jsonparser A simple json parser built using golang Installation: go get -u githu
go-nmea This is a NMEA library for the Go programming language (Golang). Features Parse individual NMEA 0183 sentences Support for sentences with NMEA
sh A shell parser, formatter, and interpreter. Supports POSIX Shell, Bash, and mksh. Requires Go 1.14 or later. Quick start To parse shell scripts, in
douceur A simple CSS parser and inliner in Golang. Parser is vaguely inspired by CSS Syntax Module Level 3 and corresponding JS parser. Inliner only p
I have a file that I ran through the function/example I sent to you on my PR:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px"
height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g id="Bounding_Box">
<rect fill="none" width="24" height="24"/>
</g>
<g id="Icons">
<g>
<g>
<path d="M2.5,19h19v2h-19V19z M19.34,15.85c0.8,0.21,1.62-0.26,1.84-1.06c0.21-0.8-0.26-1.62-1.06-1.84l-5.31-1.42l-2.76-9.02
L10.12,2v8.28L5.15,8.95L4.22,6.63L2.77,6.24v5.17L19.34,15.85z"/>
</g>
</g>
</g>
</svg>
When it called Encode on it this was the output:
<?xml version="1.0" encoding="UTF-8"?><><><!--Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0)--></><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"><g id="Bounding_Box"><rect fill="none" width="24" height="24"></rect></g><g id="Icons"><g><g><path d="M2.5,19h19v2h-19V19z M19.34,15.85c0.8,0.21,1.62-0.26,1.84-1.06c0.21-0.8-0.26-1.62-1.06-1.84l-5.31-1.42l-2.76-9.02
				L10.12,2v8.28L5.15,8.95L4.22,6.63L2.77,6.24v5.17L19.34,15.85z" fill="#f44336"></path></g></g></g></svg></>
Notice the <> and the </> are invalid XML. I even just did a Parse and then an Encode and got the same results, so its not my function for WalkMutate at all its a bug elsewhere:
xt, err := fxml.Parse(f)
if err != nil {
return
}
var buf2 bytes.Buffer
err = xt.Encode(&buf2, true)
if err != nil {
return
}
xmlString2 := buf2.String()
session_functions.IsolatedDump(xmlString2)
So as a hack I am just replacing these with nothing and it fixed this one icon until you can get back with me on why you think it's parsing it incorrectly after it encodes it:
var buf bytes.Buffer
err = newXML.Encode(&buf, true)
if err != nil {
return
}
xmlString := buf.String()
xmlString = strings.Replace(strings.Replace(xmlString, "</>", "", -1), "<>", "", -1)
data = []byte(xmlString)
Callers are expected to return x as well as the byte for whether to continue or stop
Example below can be added to docs later if you want:
var filename = "forward_10-24px.svg"
f, err := os.Open(filename)
if err != nil {
return
}
defer f.Close()
xt, err := fxml.Parse(f)
if err != nil {
return
}
newXML := xt.WalkMutate(func(ni fxml.XNodInfo, x *fxml.XMLTree) (fxml.XWalkResult, *fxml.XMLTree) {
if ni.Path[len(ni.Path)-1] == "path" {
addFill := true
for idx, _ := range x.Attr {
if x.Attr[idx].Name.Local == "fill" && x.Attr[idx].Value == "none" {
addFill = false
} else if x.Attr[idx].Name.Local == "fill" {
x.Attr[idx].Value = "red"
addFill = false
}
}
if addFill {
x.Attr = append(x.Attr, xml.Attr{
Name: xml.Name{
Local: "fill",
},
Value: "red",
})
}
}
if ni.Path[len(ni.Path)-1] == "circle" {
addFill := true
for idx, _ := range x.Attr {
if x.Attr[idx].Name.Local == "fill" && x.Attr[idx].Value == "none" {
addFill = false
} else if x.Attr[idx].Name.Local == "fill" {
x.Attr[idx].Value = "red"
addFill = false
}
}
if addFill {
x.Attr = append(x.Attr, xml.Attr{
Name: xml.Name{
Local: "fill",
},
Value: "red",
})
}
}
if ni.Path[len(ni.Path)-1] == "polygon" {
x.Attr = append(x.Attr, xml.Attr{
Name: xml.Name{
Local: "style",
},
Value: "fill: red;",
})
}
if ni.Path[len(ni.Path)-1] == "rect" {
addFill := true
for idx, _ := range x.Attr {
if x.Attr[idx].Name.Local == "fill" && x.Attr[idx].Value == "none" {
addFill = false
} else if x.Attr[idx].Name.Local == "fill" {
x.Attr[idx].Value = "red"
addFill = false
}
}
if addFill {
x.Attr = append(x.Attr, xml.Attr{
Name: xml.Name{
Local: "style",
},
Value: "fill: red;",
})
}
}
return fxml.WRCont, x
})
newXML.Encode(os.Stdout, true)
Here is the forward svg file:
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px"
height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g id="Bounding_Box">
<rect fill="none" width="24" height="24"/>
</g>
<g id="Icons">
<g>
<path d="M18,13c0,3.31-2.69,6-6,6s-6-2.69-6-6s2.69-6,6-6v4l5-5l-5-5v4c-4.42,0-8,3.58-8,8c0,4.42,3.58,8,8,8s8-3.58,8-8H18z"/>
<polygon points="10.86,15.94 10.86,11.67 10.77,11.67 9,12.3 9,12.99 10.01,12.68 10.01,15.94 "/>
<path d="M12.25,13.44v0.74c0,1.9,1.31,1.82,1.44,1.82c0.14,0,1.44,0.09,1.44-1.82v-0.74c0-1.9-1.31-1.82-1.44-1.82
C13.55,11.62,12.25,11.53,12.25,13.44z M14.29,13.32v0.97c0,0.77-0.21,1.03-0.59,1.03c-0.38,0-0.6-0.26-0.6-1.03v-0.97
c0-0.75,0.22-1.01,0.59-1.01C14.07,12.3,14.29,12.57,14.29,13.32z"/>
</g>
</g>
</svg>
Also added a bug fix for the lower cased utf-8 example.
Nice job on this. Super useful package for parsing SVGs which I needed to do here.
pfcfg-parser version 0.0.1 : 13 January 2022 A quick and simple parser for PFSense XML configuration files to generate a plain text file of the main c
xmlquery Overview xmlquery is an XPath query package for XML documents, allowing you to extract data or evaluate from XML documents with an XPath expr
Go Draw - Golang MX This package provides types and helper functions to do some basic but useful things with mxGraph diagrams in XML, which is most fa
mxj - to/from maps, XML and JSON Decode/encode XML to/from map[string]interface{} (or JSON) values, and extract/modify values from maps by key or key-
xj2go The goal is to convert xml or json file to go struct file. Usage Download and install it: $ go get -u -v github.com/wk30/xj2go/cmd/... $ xj [-t
etree The etree package is a lightweight, pure go package that expresses XML in the form of an element tree. Its design was inspired by the Python Ele
gotestsum gotestsum runs tests using go test --json, prints formatted test output, and a summary of the test run. It is designed to work well for both
Install go get github.com/turk/go-sitemap Example for sitemapindex func () main(c *gin.Context) { s := sitemap.NewSitemapIndex(c.Writer, true)
go_policyExtractor Extraction politique de conformité : xlsx (fichier de suivi) -> xml (format AlgoSec). Le programme suivant se base sur les intitulé
axmlfmt axmlfmt is an opinionated formatter for Android XML resources. It takes XML that looks like <?xml version="1.0" encoding="utf-8"?> <LinearLayo