XMLParser.jl
A lightweight XML parser which is purely written in Julia.
For extensive use of XML features, consider using one of the following XML-libraries: LightXML.jl, EzXML.jl.
Install
import Pkg
Pkg.add("XMLParser")Unsupported features
- It is not allowed to use one of the following characters in XML content:
<,>
There are probably many more XML features that are not supported at the moment.
Types
XMLParser.XMLAttribute — TypeXMLAttribute
Creates a XML attribute key-value-pair
XMLAttribute(key::String, val::String)
XMLParser.XMLTag — TypeXMLTag
Creates a XML tag
XMLTag(name::String, attributes::Vector{XMLAttribute})
Missing docstring for XMLEmptyTag. Check Documenter's build log for details.
XMLParser.XMLElement — TypeXMLElement <: AbstractXMLElement
Creates a XML element
XMLElement(tag::XMLTag, content::Vector{Any})
Functions
Utils
XMLParser.getElements! — FunctiongetElements!(ret::Vector{XMLElement},xmlel::XMLElement,tagname::String)
Pushes all XMLElements that match the tagname to ret.
XMLParser.getElements — FunctiongetElements(xmlel::XMLElement,tagname::String)
Gets all XMLElements that match the tagname and returns a Vector{XMLElement}.
XMLParser.getChildrenbyTagName! — FunctiongetChildrenbyTagName!(ret::Vector{XMLElement},xmlel::XMLElement,tagname::String)
Pushes all XMLElements that are direct children of xmlel and match the tagname to ret.
XMLParser.getChildrenbyTagName — FunctiongetChildrenbyTagName(xmlel::XMLElement,tagname::String)
Gets all XMLElements that are direct children of xmlel and match the tagname. Return a Vector{XMLElement}.
XMLParser.hasAttributekey — FunctionhasAttributekey(el::XMLElement,key::String))
Return true if el has a attribute with keyname key. Returns false otherwise.
XMLParser.getAttribute — FunctiongetAttribute(el::XMLElement,key::String)
Return attribute value if el has a attribute with keyname key. Returns emptystring otherwise.
XMLParser.setAttribute — FunctionsetAttribute(el::XMLElement,key::String,val)
Sets attribute value val to XML attribute key of XMLElement el. Returns an error("Attribute not found") if key is not found. Returns nothing otherwise.
IO-Functions
Base.read — MethodBase.read(::Type{XMLElement}, file::String)
Reads a XML file in location file. Returns a XMLElement.
XMLParser.writeXMLElement — FunctionwriteXMLElement(f::IOStream, el::XMLElement)
Writes a XMLElement to an IOStream.
writeXMLElement(f::IOStream, el::XMLElement)
Writes a XMLElement to an IOStream.