This is a Clojure wrapper around the Java VTD-XML parser, which provides very fast XML parsing.
This is a Clojure wrapper around the Java VTD-XML parser, which provides very fast XML parsing.
(all-matches navigator xpath)
(all-matches navigator xpath ns-hash)
Returns a lazy seq of the content of all nodes matching the specified XPATH. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!
Returns a lazy seq of the content of all nodes matching the specified XPATH. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!
(attr-name xpath)
Returns the attribute name from an xpath expression. This is the text after the @ sign. Param xpath is a string. Returns the entire string if there is no @ sign, or if there's nothing after the @ sign. For example, if xpath is '/company/address/@city', this will return 'city'.
Returns the attribute name from an xpath expression. This is the text after the @ sign. Param xpath is a string. Returns the entire string if there is no @ sign, or if there's nothing after the @ sign. For example, if xpath is '/company/address/@city', this will return 'city'.
(attribute-text navigator attribute-name)
Returns the text content of the attribute that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.
Returns the text content of the attribute that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.
(attribute? navigator)
Returns true if the navigator is pointing to an attribute.
Returns true if the navigator is pointing to an attribute.
(element-text navigator)
Returns the text content of the element that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.
Returns the text content of the element that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.
(element? navigator)
Returns true if the navigator is pointing to an element.
Returns true if the navigator is pointing to an element.
(find-indexes navigator xpath)
(find-indexes navigator xpath ns-hash)
Returns a lazy seq of VTDNav objects, one for each element in the XML doc that matches the specified xpath. VTDNav objects are merely pointers to positions within the byte stream. You can pass each of these objects to the content function to extract the text content, or pass them to the the raw-xml function to retrieve the literal XML string.
Returns a lazy seq of VTDNav objects, one for each element in the XML doc that matches the specified xpath. VTDNav objects are merely pointers to positions within the byte stream. You can pass each of these objects to the content function to extract the text content, or pass them to the the raw-xml function to retrieve the literal XML string.
(first-match navigator xpath)
(first-match navigator xpath ns-hash)
Returns the text content of the first node within the navigator that matches the specified XPATH expression. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!
Returns the text content of the first node within the navigator that matches the specified XPATH expression. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!
(get-hash navigator xpath)
(get-hash navigator xpath ns-hash)
Converts the XML element(s) at the specified xpath to a seq of hashes, using a fast SAX parser. The seq will contain one hash for each element that matched the xpath expression.
The xpath expression should return an element, not an attribute, because the SAX parser is expecting XML markup.
If your xpath leads to an attribute, use (all-matches nav xpath) to retrieve the value.
Some text values within the hash may have leading, trailing, and embedded spaces. You can call (normalize-text str) to get rid of these.
This function uses clojure.xml/parse, so an XML node like this:
<Employee role="Elected Member"> <Name>John McCain</Name> </Employee>
Will yield a hash structure like this:
{:tag :Employee, :attrs {:role "Elected Member"}, :content [{:tag :Name, :attrs nil, :content ["John McCain"]}]}
Converts the XML element(s) at the specified xpath to a seq of hashes, using a fast SAX parser. The seq will contain one hash for each element that matched the xpath expression. The xpath expression should return an element, not an attribute, because the SAX parser is expecting XML markup. If your xpath leads to an attribute, use (all-matches nav xpath) to retrieve the value. Some text values within the hash may have leading, trailing, and embedded spaces. You can call (normalize-text str) to get rid of these. This function uses clojure.xml/parse, so an XML node like this: <Employee role="Elected Member"> <Name>John McCain</Name> </Employee> Will yield a hash structure like this: {:tag :Employee, :attrs {:role "Elected Member"}, :content [{:tag :Name, :attrs nil, :content ["John McCain"]}]}
(get-xml navigator xpath)
(get-xml navigator xpath ns-hash)
Returns a lazy seq of the literal XML of all nodes matching the specified xpath. Each item in the seq is a string. Param nav is a VTDNav object, which you can create with the navigator function.
Returns a lazy seq of the literal XML of all nodes matching the specified xpath. Each item in the seq is a string. Param nav is a VTDNav object, which you can create with the navigator function.
(is-within? nav1 nav2)
(is-within? navigator start end)
Returns true if the element that nav2 points to is inside of the element that nav1 is pointing to.
Returns true if the navigator is pointing to an element whose start position is between start and end.
Returns true if the element that nav2 points to is inside of the element that nav1 is pointing to. Returns true if the navigator is pointing to an element whose start position is between start and end.
(navigator xml-string namespace-aware)
Given an XML string, returns a VTDNav object. Param namespace-aware is a boolean indicating whether the navigator should take XML namespaces into account.
Given an XML string, returns a VTDNav object. Param namespace-aware is a boolean indicating whether the navigator should take XML namespaces into account.
(node-name navigator)
Returns the name of the element the navigator is currently pointing to.
Returns the name of the element the navigator is currently pointing to.
(normalize-text string)
Removes leading and trailing spaces. Collapses multiple spaces within the string to a single space.
Removes leading and trailing spaces. Collapses multiple spaces within the string to a single space.
(position navigator)
Returns a hash with keys :offset and :length describing where in the byte stream the current element begins and how long it is.
Returns a hash with keys :offset and :length describing where in the byte stream the current element begins and how long it is.
(raw-xml-stream navigator)
Returns a ByteArrayInputStream of the xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. This stream is suitable for feeding to a SAX reader, or to the get-hash function. Note that if your xpath specifies an attribute, you will get the entire element that is the parent of that attribute.
Returns a ByteArrayInputStream of the xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. This stream is suitable for feeding to a SAX reader, or to the get-hash function. Note that if your xpath specifies an attribute, you will get the entire element that is the parent of that attribute.
(raw-xml-string navigator)
Returns the raw xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. Even if your xpath specified an attribute, you will get XML for the entire element that contains that attribute.
Returns the raw xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. Even if your xpath specified an attribute, you will get XML for the entire element that contains that attribute.
(to-first-child! navigator)
(to-first-child! navigator element-name)
Moves the VTDNav object's cursor to the first child of whatever element it's currently pointing to. This changes the navigator's internal pointer!
Moves the VTDNav object's cursor to the first child of whatever element it's currently pointing to. This changes the navigator's internal pointer!
(to-last-child! navigator)
(to-last-child! navigator element-name)
Moves the VTDNav object's cursor to the last child of whatever element it's currently pointing to. This changes the navigator's internal pointer!
Moves the VTDNav object's cursor to the last child of whatever element it's currently pointing to. This changes the navigator's internal pointer!
(to-next-sibling! navigator)
(to-next-sibling! navigator element-name)
Moves the VTDNav object's cursor to the next sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!
Moves the VTDNav object's cursor to the next sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!
(to-parent! navigator)
Moves the VTDNav object's cursor to the parent of whatever element it's currently pointing to. This changes the navigator's internal pointer!
Moves the VTDNav object's cursor to the parent of whatever element it's currently pointing to. This changes the navigator's internal pointer!
(to-prev-sibling! navigator)
(to-prev-sibling! navigator element-name)
Moves the VTDNav object's cursor to the previous sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!
Moves the VTDNav object's cursor to the previous sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!
(token-type navigator)
Returns the type of token at the current navigator index. This is an integer which you can test against the following enumeration.
0 com.ximpleware.VTDNav/TOKEN_STARTING_TAG 1 com.ximpleware.VTDNav/TOKEN_ENDING_TAG 2 com.ximpleware.VTDNav/TOKEN_ATTR_NAME 3 com.ximpleware.VTDNav/TOKEN_ATTR_NS 4 com.ximpleware.VTDNav/TOKEN_ATTR_VAL 5 com.ximpleware.VTDNav/TOKEN_CHARACTER_DATA 6 com.ximpleware.VTDNav/TOKEN_COMMENT 7 com.ximpleware.VTDNav/TOKEN_PI_NAME 8 com.ximpleware.VTDNav/TOKEN_PI_VAL 9 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_NAME 10 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_VAL 11 com.ximpleware.VTDNav/TOKEN_CDATA_VAL 12 com.ximpleware.VTDNav/TOKEN_DTD_VAL 13 com.ximpleware.VTDNav/TOKEN_DOCUMENT
Returns the type of token at the current navigator index. This is an integer which you can test against the following enumeration. 0 com.ximpleware.VTDNav/TOKEN_STARTING_TAG 1 com.ximpleware.VTDNav/TOKEN_ENDING_TAG 2 com.ximpleware.VTDNav/TOKEN_ATTR_NAME 3 com.ximpleware.VTDNav/TOKEN_ATTR_NS 4 com.ximpleware.VTDNav/TOKEN_ATTR_VAL 5 com.ximpleware.VTDNav/TOKEN_CHARACTER_DATA 6 com.ximpleware.VTDNav/TOKEN_COMMENT 7 com.ximpleware.VTDNav/TOKEN_PI_NAME 8 com.ximpleware.VTDNav/TOKEN_PI_VAL 9 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_NAME 10 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_VAL 11 com.ximpleware.VTDNav/TOKEN_CDATA_VAL 12 com.ximpleware.VTDNav/TOKEN_DTD_VAL 13 com.ximpleware.VTDNav/TOKEN_DOCUMENT
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close