https://github.com/orisano/gosax Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + GitHub Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} orisano / gosax Public * Notifications You must be signed in to change notification settings * Fork 0 * Star 73 Go library for XML SAX (Simple API for XML) parsing License View license 73 stars 0 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights orisano/gosax This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 8 Commits _samples _samples LICENSE LICENSE README.md README.md bench_test.go bench_test.go compat.go compat.go example_test.go example_test.go go.mod go.mod gosax.go gosax.go reader.go reader.go View all files Repository files navigation * README * License gosax Go Reference gosax is a Go library for XML SAX (Simple API for XML) parsing, supporting read-only functionality. This library is designed for efficient and memory-conscious XML parsing, drawing inspiration from various sources to provide a performant parser. Features * Read-only SAX parsing: Stream and process XML documents without loading the entire document into memory. * Efficient parsing: Utilizes techniques inspired by quick-xml and pkg/json for high performance. * SWAR (SIMD Within A Register): Optimizations for fast text processing, inspired by memchr. * Compatibility with encoding/xml: Includes utility functions to bridge gosax types with encoding/xml types, facilitating easy integration with existing code that uses the standard library. Benchmark goos: darwin goarch: arm64 pkg: github.com/orisano/gosax BenchmarkReader_Event-12 5 211845800 ns/op 1103.30 MB/s 2097606 B/op 6 allocs/op Installation To install gosax, use go get: go get github.com/orisano/gosax Usage Here is a basic example of how to use gosax to parse an XML document: package main import ( "fmt" "log" "strings" "github.com/orisano/gosax" ) func main() { xmlData := `Value` reader := strings.NewReader(xmlData) r := gosax.NewReader(reader) for { e, err := r.Event() if err != nil { log.Fatal(err) } if e.Type() == gosax.EventEOF { break } fmt.Println(string(e.Bytes)) } // Output: // // // Value // // } Bridging with encoding/xml gosax provides utility functions to convert its types to encoding/xml types: This allows for easy integration with existing code that uses the standard library's XML package. import ( "encoding/xml" "github.com/orisano/gosax" ) // ... event, _ := r.Event() if event.Type() == gosax.EventStart { startElement, err := gosax.StartElement(event.Bytes) // Now you can use startElement as an xml.StartElement // ... } License This library is licensed under the terms specified in the LICENSE file. Acknowledgements gosax is inspired by the following projects and resources: * Dave Cheney's GopherCon SG 2023 Talk * quick-xml * memchr (SWAR part) Contributing Contributions are welcome! Please fork the repository and submit pull requests. Contact For any questions or feedback, feel free to open an issue on the GitHub repository. About Go library for XML SAX (Simple API for XML) parsing Topics go xml sax Resources Readme License View license Activity Stars 73 stars Watchers 2 watching Forks 0 forks Report repository Releases No releases published Packages 0 No packages published Languages * Go 100.0% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.