# XML Tree Utilities

**API Group:** `xmlsec_core_xmltree`

XML-tree navigation and manipulation helper functions.

XML tree functions.

## Macros

### `xmlSecNodeGetName`

*Defined as:* `(((node)) ? ((const char*)((node)->name)) : NULL)`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L33)

Macro. Returns node's name.

**Parameters:**

- `node` — the pointer to node.

---

### `xmlSecIsHex`

*Defined as:* `(( (('0' <= (c)) && ((c) <= '9')) || \
       (('a' <= (c)) && ((c) <= 'f')) || \
       (('A' <= (c)) && ((c) <= 'F')) ) ? 1 : 0)`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L134)

Returns 1 if the character is a hex digit.

Macro. Returns 1 if `is` a hex digit or 0 other wise. 

**Parameters:**

- `c` — the character.

---

### `xmlSecGetHex`

*Defined as:* `xmlSecFromHex(ch)`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L144)

Deprecated. Returns the hex value of a character.

Deprecated. Macro. Returns the hex value of the `ch`. 

**Parameters:**

- `ch` — the character,

---

### `xmlSecFromHex`

*Defined as:* `((xmlSecByte)(                                                          \
            (('0' <= (ch)) && ((ch) <= '9')) ? (ch) - '0' :                     \
                (                                                               \
                    (('a' <= (ch)) && ((ch) <= 'f')) ? (ch) - 'a' + 10 :        \
                    (                                                           \
                        (('A' <= (ch)) && ((ch) <= 'F')) ? (ch) - 'A' + 10 : 0  \
                    )                                                           \
                )                                                               \
        ))`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L150)

Macro. Returns the hex value of the `ch`.

**Parameters:**

- `ch` — the character,

---

### `xmlSecFromHex2`

*Defined as:* `((xmlSecByte)((xmlSecFromHex(ch1) << 4) | (xmlSecFromHex(ch2))))`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L167)

Returns the hex value of a two-character pair.

Macro. Returns the hex value of the pair (`c1` `c2`). 

**Parameters:**

- `ch1` — the first character,
- `ch2` — the second character,

---

### `xmlSecToHex`

*Defined as:* `((xmlChar)(                                                     \
            ((0 <= (vv)) && ((vv) <= 9)) ? (vv) + '0' :                 \
                (                                                       \
                    ((10 <= (vv)) && ((vv) <= 15)) ? (vv) + 'A' : 0     \
                )                                                       \
        ))`

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L173)

Macro. Returns the hex character of the `vv`.

**Parameters:**

- `vv` — the value,

---

## Typedefs

### `xmlSecTreeWalkCallback`

```c
typedef int(* xmlSecTreeWalkCallback) (xmlNodePtr cur, void *data))(xmlNodePtr cur, void *data);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L120)

for XML tree walk.

**Parameters:**

- `cur` — the current XML node.
- `data` — the user data passed to the callback.


**Returns:** 1 to continue the walk, 0 to stop the walk, or a negative value to stop the walk with an error.

---

### `xmlSecQName2IntegerInfoConstPtr`

```c
typedef const xmlSecQName2IntegerInfo* xmlSecQName2IntegerInfoConstPtr;
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L203)

Pointer to constant QName <-> Integer conversion.

Pointer to constant QName <-> Integer conversion definition.

---

### `xmlSecBitMask`

```c
typedef unsigned int xmlSecBitMask;
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L255)

Bitmask datatype.

---

### `xmlSecQName2BitMaskInfoConstPtr`

```c
typedef const xmlSecQName2BitMaskInfo* xmlSecQName2BitMaskInfoConstPtr;
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L272)

Pointer to constant QName <-> Bitmask conversion.

Pointer to constant QName <-> Bitmask conversion definition.

---

## Functions

### `xmlSecGetDefaultLineFeed`

```c
const xmlChar * xmlSecGetDefaultLineFeed(void);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L36)

Gets the current default linefeed.

**Returns:** the current default linefeed.

---

### `xmlSecSetDefaultLineFeed`

```c
void xmlSecSetDefaultLineFeed(const xmlChar *linefeed);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L37)

Sets the current default linefeed.

The caller must ensure that the linefeed string exists for the lifetime of the program or until the new linefeed is set. 

**Parameters:**

- `linefeed` — default linefeed.

---

### `xmlSecGetNodeNsHref`

```c
const xmlChar * xmlSecGetNodeNsHref(const xmlNodePtr cur);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L39)

Gets the node's namespace href.

**Parameters:**

- `cur` — the pointer to node.


**Returns:** node's namespace href.

---

### `xmlSecGetNodeContentAndTrim`

```c
xmlChar * xmlSecGetNodeContentAndTrim(const xmlNodePtr cur);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L40)

Reads and trims XML node content.

Reads `cur` node content and trims it (both sides). 

**Parameters:**

- `cur` — the pointer to XML node.


**Returns:** trimmed node content or NULL if an error occurs.

---

### `xmlSecGetNodeContentAsSize`

```c
int xmlSecGetNodeContentAsSize(const xmlNodePtr cur, xmlSecSize defValue, xmlSecSize *res);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L41)

Reads node content and converts it to an `xmlSecSize`.

Reads `cur` node content and converts it to `xmlSecSize` value. 

**Parameters:**

- `cur` — the pointer to XML node.
- `defValue` — the default value that will be returned in `res` if there is no node content.
- `res` — the pointer to the result value.


**Returns:** 0 on success or -1 on error.

---

### `xmlSecGetNodeContentAsHex`

```c
int xmlSecGetNodeContentAsHex(const xmlNodePtr cur, xmlSecBufferPtr res);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L44)

Reads node content and hex-decodes it into a buffer.

Reads `cur` node content (whitespace-trimmed), hex-decodes it, and stores the result in `res`. The buffer is emptied before writing. 

**Parameters:**

- `cur` — the pointer to XML node.
- `res` — the output buffer to store the decoded bytes.


**Returns:** 0 on success or -1 on error.

---

### `xmlSecSetNodeContentAsHex`

```c
int xmlSecSetNodeContentAsHex(xmlNodePtr node, const xmlSecByte *data, xmlSecSize size);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L46)

Hex-encodes data and sets it as node content.

Hex-encodes `data` and stores the result as node content for `node`. 

**Parameters:**

- `node` — the pointer to XML node.
- `data` — the input bytes.
- `size` — the input data size.


**Returns:** 0 on success or -1 on error.

---

### `xmlSecCheckNodeName`

```c
int xmlSecCheckNodeName(const xmlNodePtr cur, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L49)

Checks if a node has the given name and namespace.

Checks that the node has a given name and a given namespace href. 

**Parameters:**

- `cur` — the pointer to an XML node.
- `name` — the name,
- `ns` — the namespace href.


**Returns:** 1 if the node matches or 0 otherwise.

---

### `xmlSecGetNextElementNode`

```c
xmlNodePtr xmlSecGetNextElementNode(xmlNodePtr cur);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L52)

Searches for the next element node.

**Parameters:**

- `cur` — the pointer to an XML node.


**Returns:** the pointer to next element node or NULL if it is not found.

---

### `xmlSecFindSibling`

```c
xmlNodePtr xmlSecFindSibling(const xmlNodePtr cur, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L53)

Searches a node and its next siblings by name and namespace.

Searches `cur` and the next siblings of the `cur` node having given name and namespace href. 

**Parameters:**

- `cur` — the pointer to XML node.
- `name` — the name.
- `ns` — the namespace href (may be NULL).


**Returns:** the pointer to the found node or NULL if an error occurs or node is not found.

---

### `xmlSecFindChild`

```c
xmlNodePtr xmlSecFindChild(const xmlNodePtr parent, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L56)

Finds a direct child node by name and namespace.

Searches a direct child of the `parent` node having given name and namespace href. 

**Parameters:**

- `parent` — the pointer to XML node.
- `name` — the name.
- `ns` — the namespace href (may be NULL).


**Returns:** the pointer to the found node or NULL if an error occurs or node is not found.

---

### `xmlSecFindParent`

```c
xmlNodePtr xmlSecFindParent(const xmlNodePtr cur, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L59)

Searches ancestor nodes by name and namespace.

Searches the ancestors axis of the `cur` node for a node having given name and namespace href. 

**Parameters:**

- `cur` — the pointer to an XML node.
- `name` — the name.
- `ns` — the namespace href (may be NULL).


**Returns:** the pointer to the found node or NULL if an error occurs or node is not found.

---

### `xmlSecFindNode`

```c
xmlNodePtr xmlSecFindNode(const xmlNodePtr parent, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L62)

Searches child nodes by name and namespace.

Searches all children of the `parent` node having given name and namespace href. 

**Parameters:**

- `parent` — the pointer to XML node.
- `name` — the name.
- `ns` — the namespace href (may be NULL).


**Returns:** the pointer to the found node or NULL if an error occurs or node is not found.

---

### `xmlSecAddChild`

```c
xmlNodePtr xmlSecAddChild(xmlNodePtr parent, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L65)

Adds a new child element with the given name and namespace.

Adds a child to the node `parent` with given `name` and namespace `ns`. 

**Parameters:**

- `parent` — the pointer to an XML node.
- `name` — the new node name.
- `ns` — the new node namespace.


**Returns:** pointer to the new node or NULL if an error occurs.

---

### `xmlSecEnsureEmptyChild`

```c
xmlNodePtr xmlSecEnsureEmptyChild(xmlNodePtr parent, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L68)

Finds or creates an empty child element by name and namespace.

Searches a direct child of the `parent` node having given name and namespace href. If not found then element node with given name / namespace is added. 

**Parameters:**

- `parent` — the pointer to XML node.
- `name` — the name.
- `ns` — the namespace href (may be NULL).


**Returns:** the pointer to the found or created node; or NULL if an error occurs.

---

### `xmlSecAddChildNode`

```c
xmlNodePtr xmlSecAddChildNode(xmlNodePtr parent, xmlNodePtr child);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L71)

Adds `child` node to the `parent` node.

**Parameters:**

- `parent` — the pointer to an XML node.
- `child` — the new node.


**Returns:** pointer to the new node or NULL if an error occurs.

---

### `xmlSecAddNextSibling`

```c
xmlNodePtr xmlSecAddNextSibling(xmlNodePtr node, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L73)

Adds a new next-sibling element with the given name and namespace.

Adds next sibling to the node `node` with given `name` and namespace `ns`. 

**Parameters:**

- `node` — the pointer to an XML node.
- `name` — the new node name.
- `ns` — the new node namespace.


**Returns:** pointer to the new node or NULL if an error occurs.

---

### `xmlSecAddPrevSibling`

```c
xmlNodePtr xmlSecAddPrevSibling(xmlNodePtr node, const xmlChar *name, const xmlChar *ns);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L76)

Adds a new previous-sibling element with the given name and namespace.

Adds prev sibling to the node `node` with given `name` and namespace `ns`. 

**Parameters:**

- `node` — the pointer to an XML node.
- `name` — the new node name.
- `ns` — the new node namespace.


**Returns:** pointer to the new node or NULL if an error occurs.

---

### `xmlSecReplaceNode`

```c
int xmlSecReplaceNode(xmlNodePtr node, xmlNodePtr newNode);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L80)

Swaps a node with a new node in the XML tree.

Swaps the `node` and `newNode` in the XML tree. 

**Parameters:**

- `node` — the current node.
- `newNode` — the new node.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecReplaceNodeAndReturn`

```c
int xmlSecReplaceNodeAndReturn(xmlNodePtr node, xmlNodePtr newNode, xmlNodePtr *replaced);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L82)

Swaps a node with another and optionally returns the replaced node.

Swaps the `node` and `newNode` in the XML tree. 

**Parameters:**

- `node` — the current node.
- `newNode` — the new node.
- `replaced` — the replaced node, or release it if NULL is given


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecReplaceContent`

```c
int xmlSecReplaceContent(xmlNodePtr node, xmlNodePtr newNode);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L86)

Swaps the content of `node` and `newNode`.

**Parameters:**

- `node` — the current node.
- `newNode` — the new node.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecReplaceContentAndReturn`

```c
int xmlSecReplaceContentAndReturn(xmlNodePtr node, xmlNodePtr newNode, xmlNodePtr *replaced);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L88)

Swaps the content of `node` and `newNode`, optionally returning replaced nodes.

**Parameters:**

- `node` — the current node.
- `newNode` — the new node.
- `replaced` — the replaced nodes, or release them if NULL is given


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecReplaceNodeBuffer`

```c
int xmlSecReplaceNodeBuffer(xmlNodePtr node, const xmlSecByte *buffer, xmlSecSize size);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L92)

Replaces a node with parsed XML data from a buffer.

Swaps the `node` and the parsed XML data from the `buffer` in the XML tree. 

**Parameters:**

- `node` — the current node.
- `buffer` — the XML data.
- `size` — the XML data size.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecReplaceNodeBufferAndReturn`

```c
int xmlSecReplaceNodeBufferAndReturn(xmlNodePtr node, const xmlSecByte *buffer, xmlSecSize size, xmlNodePtr *replaced);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L95)

Replaces a node with parsed XML data from a buffer, optionally returning replaced nodes.

Swaps the `node` and the parsed XML data from the `buffer` in the XML tree. 

**Parameters:**

- `node` — the current node.
- `buffer` — the XML data.
- `size` — the XML data size.
- `replaced` — the replaced nodes, or release them if NULL is given


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecNodeEncodeAndSetContent`

```c
int xmlSecNodeEncodeAndSetContent(xmlNodePtr node, const xmlChar *buffer);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L100)

Encodes special characters in a buffer and sets it as node content.

Encodes "special" characters in the `buffer` and sets the result as the node content. 

**Parameters:**

- `node` — the pointer to an XML node.
- `buffer` — the pointer to the node content.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecAddIDs`

```c
void xmlSecAddIDs(xmlDocPtr doc, xmlNodePtr node, const xmlChar **ids);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L103)

Registers ID attributes from a node subtree in the document's ID table.

Walks thru all children of the `node` and adds all attributes from the `ids` list to the `doc` document IDs attributes hash. 

**Parameters:**

- `doc` — the pointer to an XML document.
- `node` — the pointer to an XML node.
- `ids` — the pointer to a NULL terminated list of ID attributes.

---

### `xmlSecCreateTree`

```c
xmlDocPtr xmlSecCreateTree(const xmlChar *rootNodeName, const xmlChar *rootNodeNs);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L106)

Creates a new XML document with a single root node.

Creates a new XML tree with one root node `rootNodeName`. 

**Parameters:**

- `rootNodeName` — the root node name.
- `rootNodeNs` — the root node namespace (optional).


**Returns:** pointer to the newly created tree or NULL if an error occurs.

---

### `xmlSecIsEmptyNode`

```c
int xmlSecIsEmptyNode(xmlNodePtr node);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L108)

Checks whether a node is empty (whitespace only).

Checks whether the `node` is empty (i.e. has only whitespaces children). 

**Parameters:**

- `node` — the node to check


**Returns:** 1 if `node` is empty, 0 otherwise or a negative value if an error occurs.

---

### `xmlSecIsEmptyString`

```c
int xmlSecIsEmptyString(const xmlChar *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L109)

Checks whether a string contains only whitespace.

Checks whether the `str` is empty (i.e. has only whitespaces children). 

**Parameters:**

- `str` — the string to check


**Returns:** 1 if `str` is empty, 0 otherwise or a negative value if an error occurs.

---

### `xmlSecGetQName`

```c
xmlChar * xmlSecGetQName(xmlNodePtr node, const xmlChar *href, const xmlChar *local);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L110)

Creates a QName string from a namespace href and a local name.

Creates QName (prefix:local) from `href` and `local` in the context of the `node`. Caller is responsible for freeing returned string with xmlFree. 

**Parameters:**

- `node` — the context node.
- `href` — the QName href (can be NULL).
- `local` — the QName local part.


**Returns:** qname or NULL if an error occurs.

---

### `xmlSecDepthFirstTreeWalk`

```c
int xmlSecDepthFirstTreeWalk(xmlNodePtr node, xmlSecTreeWalkCallback callback, void *data);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L122)

Walks thru the XML tree and calls a callback for each node.

Walks thru the XML tree starting from `node` and calls `callback` for each node. The `callback` is called with the current node and `data` as parameters and should return 1 to continue the walk, 0 to stop the walk, or a negative value to stop the walk with an error. 

**Parameters:**

- `node` — the pointer to an XML node to start the walk from.
- `callback` — the callback function to call for each node.
- `data` — the pointer to data to pass to the callback function.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecPrintXmlString`

```c
int xmlSecPrintXmlString(FILE *fd, const xmlChar *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L126)

Encodes an XML string and writes it to a file descriptor.

Encodes the `str` (e.g. replaces '&' with '&') and writes it to `fd`. 

**Parameters:**

- `fd` — the file descriptor to write the XML string to
- `str` — the string


**Returns:** he number of bytes transmitted or a negative value if an error occurs.

---

### `xmlSecQName2IntegerGetInfo`

```c
xmlSecQName2IntegerInfoConstPtr xmlSecQName2IntegerGetInfo(xmlSecQName2IntegerInfoConstPtr info, int intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L205)

Maps integer `intValue` to a QName prefix.

**Parameters:**

- `info` — the qname<->integer mapping information.
- `intValue` — the integer value.


**Returns:** the QName info that is mapped to `intValue` or NULL if such value is not found.

---

### `xmlSecQName2IntegerGetInteger`

```c
int xmlSecQName2IntegerGetInteger(xmlSecQName2IntegerInfoConstPtr info, const xmlChar *qnameHref, const xmlChar *qnameLocalPart, int *intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L208)

Maps a QName to an integer value.

Maps qname qname to an integer and returns it in `intValue`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `qnameHref` — the qname href value.
- `qnameLocalPart` — the qname local part value.
- `intValue` — the pointer to result integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerGetIntegerFromString`

```c
int xmlSecQName2IntegerGetIntegerFromString(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, const xmlChar *qname, int *intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L212)

Converts a QName string to an integer value.

Converts `qname` into integer in context of `node`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the pointer to node.
- `qname` — the qname string.
- `intValue` — the pointer to result integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerGetStringFromInteger`

```c
xmlChar * xmlSecQName2IntegerGetStringFromInteger(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, int intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L217)

Creates a QName string from an integer value.

Creates qname string for `intValue` in context of given `node`. Caller is responsible for freeing returned string with `xmlFree`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the pointer to node.
- `intValue` — the integer value.


**Returns:** pointer to newly allocated string on success or NULL if an error occurs,

---

### `xmlSecQName2IntegerNodeRead`

```c
int xmlSecQName2IntegerNodeRead(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, int *intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L221)

Reads a node's content and converts it to an integer using QName mapping.

Reads the content of `node` and converts it to an integer using mapping from `info`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the pointer to node.
- `intValue` — the pointer to result integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerNodeWrite`

```c
int xmlSecQName2IntegerNodeWrite(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, const xmlChar *nodeName, const xmlChar *nodeNs, int intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L224)

Creates a child node holding a QName string for an integer value.

Creates new child node in `node` and sets its value to `intValue`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the parent node.
- `nodeName` — the child node name.
- `nodeNs` — the child node namespace.
- `intValue` — the integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerAttributeRead`

```c
int xmlSecQName2IntegerAttributeRead(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, const xmlChar *attrName, int *intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L229)

Reads an attribute's QName value and converts it to an integer.

Gets the value of `attrName` atrtibute from `node` and converts it to integer according to `info`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the element node.
- `attrName` — the attribute name.
- `intValue` — the pointer to result integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerAttributeWrite`

```c
int xmlSecQName2IntegerAttributeWrite(xmlSecQName2IntegerInfoConstPtr info, xmlNodePtr node, const xmlChar *attrName, int intValue);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L233)

Converts an integer to a QName and sets it as an attribute value.

Converts `intValue` to a qname and sets it to the value of attribute `attrName` in `node`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the parent node.
- `attrName` — the name of attribute.
- `intValue` — the integer value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2IntegerDebugDump`

```c
void xmlSecQName2IntegerDebugDump(xmlSecQName2IntegerInfoConstPtr info, int intValue, const xmlChar *name, FILE *output);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L237)

Prints `intValue` into `output`.

**Parameters:**

- `info` — the qname<->integer mapping information.
- `intValue` — the integer value.
- `name` — the value name to print.
- `output` — the pointer to output FILE.

---

### `xmlSecQName2IntegerDebugXmlDump`

```c
void xmlSecQName2IntegerDebugXmlDump(xmlSecQName2IntegerInfoConstPtr info, int intValue, const xmlChar *name, FILE *output);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L241)

Prints `intValue` into `output` in XML format.

**Parameters:**

- `info` — the qname<->integer mapping information.
- `intValue` — the integer value.
- `name` — the value name to print.
- `output` — the pointer to output FILE.

---

### `xmlSecQName2BitMaskGetInfo`

```c
xmlSecQName2BitMaskInfoConstPtr xmlSecQName2BitMaskGetInfo(xmlSecQName2BitMaskInfoConstPtr info, xmlSecBitMask mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L274)

Converts `mask` to qname.

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `mask` — the bit mask.


**Returns:** pointer to the qname info for `mask` or NULL if mask is unknown.

---

### `xmlSecQName2BitMaskGetBitMask`

```c
int xmlSecQName2BitMaskGetBitMask(xmlSecQName2BitMaskInfoConstPtr info, const xmlChar *qnameLocalPart, const xmlChar *qnameHref, xmlSecBitMask *mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L277)

Converts `qnameLocalPart` to `mask`.

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `qnameHref` — the qname Href value.
- `qnameLocalPart` — the qname LocalPart value.
- `mask` — the pointer to result mask.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2BitMaskNodesRead`

```c
int xmlSecQName2BitMaskNodesRead(xmlSecQName2BitMaskInfoConstPtr info, xmlNodePtr *node, const xmlChar *nodeName, const xmlChar *nodeNs, int stopOnUnknown, xmlSecBitMask *mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L281)

Reads QName elements and accumulates their values into a bit mask.

Reads <`nodeNs:` and puts the result bit mask into `mask`. When function exits, `node` points to the first element node after all the <`nodeNs:`. 

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `node` — the start.
- `nodeName` — the mask nodes name.
- `nodeNs` — the mask nodes namespace.
- `stopOnUnknown` — if this flag is set then function exits if unknown value was found.
- `mask` — the pointer to result mask.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2BitMaskGetBitMaskFromString`

```c
int xmlSecQName2BitMaskGetBitMaskFromString(xmlSecQName2BitMaskInfoConstPtr info, xmlNodePtr node, const xmlChar *qname, xmlSecBitMask *mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L287)

Converts a QName string to a bit mask value.

Converts `qname` into integer in context of `node`. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the pointer to node.
- `qname` — the qname string.
- `mask` — the pointer to result msk value.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2BitMaskGetStringFromBitMask`

```c
xmlChar * xmlSecQName2BitMaskGetStringFromBitMask(xmlSecQName2BitMaskInfoConstPtr info, xmlNodePtr node, xmlSecBitMask mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L292)

Creates a QName string from a bit mask value.

Creates qname string for `mask` in context of given `node`. Caller is responsible for freeing returned string with xmlFree. 

**Parameters:**

- `info` — the qname<->integer mapping information.
- `node` — the pointer to node.
- `mask` — the mask.


**Returns:** pointer to newly allocated string on success or NULL if an error occurs,

---

### `xmlSecQName2BitMaskNodesWrite`

```c
int xmlSecQName2BitMaskNodesWrite(xmlSecQName2BitMaskInfoConstPtr info, xmlNodePtr node, const xmlChar *nodeName, const xmlChar *nodeNs, xmlSecBitMask mask);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L296)

Writes bit mask values as QName child elements.

Writes <`nodeNs:` with values from `mask` to `node`. 

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `node` — the parent element for mask nodes.
- `nodeName` — the mask nodes name.
- `nodeNs` — the mask nodes namespace.
- `mask` — the bit mask.


**Returns:** 0 on success or a negative value if an error occurs,

---

### `xmlSecQName2BitMaskDebugDump`

```c
void xmlSecQName2BitMaskDebugDump(xmlSecQName2BitMaskInfoConstPtr info, xmlSecBitMask mask, const xmlChar *name, FILE *output);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L301)

Prints debug information about a bit mask.

Prints debug information about `mask` to `output`. 

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `mask` — the bit mask.
- `name` — the value name to print.
- `output` — the pointer to output FILE.

---

### `xmlSecQName2BitMaskDebugXmlDump`

```c
void xmlSecQName2BitMaskDebugXmlDump(xmlSecQName2BitMaskInfoConstPtr info, xmlSecBitMask mask, const xmlChar *name, FILE *output);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L305)

Prints debug information about a bit mask in XML format.

Prints debug information about `mask` to `output` in XML format. 

**Parameters:**

- `info` — the qname<->bit mask mapping information.
- `mask` — the bit mask.
- `name` — the value name to print.
- `output` — the pointer to output FILE.

---

### `xmlSecWin32ConvertLocaleToUnicode`

```c
wchar_t * xmlSecWin32ConvertLocaleToUnicode(const char *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L317)

Converts input string from current system locale to Unicode.

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertUtf8ToUnicode`

```c
wchar_t * xmlSecWin32ConvertUtf8ToUnicode(const xmlChar *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L319)

Converts input string from UTF8 to Unicode.

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertUnicodeToUtf8`

```c
xmlChar * xmlSecWin32ConvertUnicodeToUtf8(const \ wchar_t *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L320)

Converts input string from Unicode to UTF8.

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertLocaleToUtf8`

```c
xmlChar * xmlSecWin32ConvertLocaleToUtf8(const char *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L322)

Converts input string from locale to UTF8.

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertUtf8ToLocale`

```c
char * xmlSecWin32ConvertUtf8ToLocale(const xmlChar *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L323)

Converts input string from UTF8 to locale.

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertTstrToUtf8`

```c
xmlChar * xmlSecWin32ConvertTstrToUtf8(const \ char *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L325)

Converts a TSTR string (locale or Unicode) to UTF-8.

Converts input string from TSTR (locale or Unicode) to UTF8. 

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---

### `xmlSecWin32ConvertUtf8ToTstr`

```c
char * xmlSecWin32ConvertUtf8ToTstr(const xmlChar *str);
```

*Source:* [include/xmlsec/xmltree.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/xmltree.h#L326)

Converts a UTF-8 string to TSTR (locale or Unicode).

Converts input string from UTF8 to TSTR (locale or Unicode). 

**Parameters:**

- `str` — the string to convert.


**Returns:** a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.

---
