Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
github.com/imqs/simplexml
simplexml provides a simple API to read, create and manipulate XML documents at run time in pure Go.
simplxml underwent a major refactor for v0.1 in order to address comment support and a few other annoyances I had with the API. simplexml is now entering a more stable state as of v0.1. While trunk is not guaranteed to be clear of breaking changes, they will be well documented moving forward, and tags will be available of older releases. Please remember to vendor your dependencies :)
root := NewTag("root") // a tag is an element that can contain other elements
doc := NewDocument(root) // a document can only contain one root tag
doc.AddBefore(NewComment("simplexml has support for comments outside of the root document"), root)
root.AddAfter(NewTag("foo"), nil) // a nil pointer can be given to append to the end of all elements
root.AddBefore(NewTag("bar"), nil) // or prepend before all elements
bat := NewTag("bat")
bat.AddAfter(NewValue("bat value"), nil)
root.AddAfter(bat, nil)
b, err := doc.Marshal() // a simplexml document implements the Marshaler interface
if err != nil {
panic(err)
}
fmt.Println(string(b))
//Output:
//<!--simplexml has support for comments outside of the root document--><root><bar/><foo/><bat>bat value</bat></root>
xmlString := `<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!-- comment above root element -->
<root>
<!-- <comment>above foo</comment> -->
<foo>
<bar>bat</bar>
<baz/>
<fizz><![CDATA[<foo>contents</foo>]]></fizz>
</foo>
</root>
<!-- comment below root element -->`
// create a document from a reader
doc, err := NewDocumentFromReader(strings.NewReader(xmlString))
if err != nil {
panic(err)
}
// get the fizz tag and value
fizz := doc.Root().Search().ByName("foo").ByName("fizz").One()
if fizz == nil {
panic("fizz is missing")
}
fv, err := fizz.Value()
if err != nil {
panic(err)
}
fmt.Println("fizz: ", fv)
//Output:
//fizz: <foo>contents</foo>
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.