---
name: "libwget-xml"
section: "3"
platform: "linux"
package: "wget2-dev"
version: "2.2.0+ds-1+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libwget-xml"
---

# libwget-xml(3)

XML parsing functions

## NAME

libwget-xml - XML parsing functions

## SYNOPSIS

### Functions

int **wget\_xml\_parse\_buffer** (const char \*buf, wget\_xml\_callback \*callback, void \*user\_ctx, int hints)\
 void **wget\_html\_parse\_buffer** (const char \*buf, wget\_xml\_callback \*callback, void \*user\_ctx, int hints)\
 void **wget\_xml\_parse\_file** (const char \*fname, wget\_xml\_callback \*callback, void \*user\_ctx, int hints)\
 void **wget\_html\_parse\_file** (const char \*fname, wget\_xml\_callback \*callback, void \*user\_ctx, int hints)\
 char \* **wget\_xml\_decode\_entities\_inline** (char \*src)\

## Detailed Description

## Function Documentation

### int wget\_xml\_parse\_buffer (const char \* buf, wget\_xml\_callback \* callback, void \* user\_ctx, int hints)

**Parameters**

*buf* Zero-terminated XML or HTML input data \
 *callback* Function called for each token scan result \
 *user\_ctx* User-defined context variable, handed to `callback` \
 *hints* Flags to influence parsing

This function scans the XML input from `buf` and calls `callback` for each token found. `user_ctx` is a user-defined context variable and given to each call of `callback`.

`hints` may be 0 or any combination of XML\_HINT\_REMOVE\_EMPTY\_CONTENT and XML\_HINT\_HTML.

XML\_HINT\_REMOVE\_EMPTY\_CONTENT reduces the number of calls to `callback` by ignoring empty content and superfluous spaces.

XML\_HINT\_HTML turns on HTML scanning.

### void wget\_html\_parse\_buffer (const char \* buf, wget\_xml\_callback \* callback, void \* user\_ctx, int hints)

**Parameters**

*buf* Zero-terminated HTML input data \
 *callback* Function called for each token scan result \
 *user\_ctx* User-defined context variable, handed to `callback` \
 *hints* Flags to influence parsing

Convenience function that calls **wget\_xml\_parse\_buffer()** with HTML parsing turned on.

### void wget\_xml\_parse\_file (const char \* fname, wget\_xml\_callback \* callback, void \* user\_ctx, int hints)

**Parameters**

*fname* Name of XML or HTML input file \
 *callback* Function called for each token scan result \
 *user\_ctx* User-defined context variable, handed to `callback` \
 *hints* Flags to influence parsing

Convenience function that calls **wget\_xml\_parse\_buffer()** with the file content.

If `fname` is `-`, the data is read from stdin.

### void wget\_html\_parse\_file (const char \* fname, wget\_xml\_callback \* callback, void \* user\_ctx, int hints)

**Parameters**

*fname* Name of XML or HTML input file \
 *callback* Function called for each token scan result \
 *user\_ctx* User-defined context variable, handed to `callback` \
 *hints* Flags to influence parsing

Convenience function that calls **wget\_xml\_parse\_file()** with HTML parsing turned on.

If `fname` is `-`, the data is read from stdin.

### char \* wget\_xml\_decode\_entities\_inline (char \* src)

**Parameters**

*src* A string

**Returns**

A pointer to `src`, after the XML entities have been converted

Decode XML entities from `src`.

**The transformation is done inline**, so `src` will be modified after this function returns. If no XML entities have been found, `src` is left untouched.

Only a small subset of available XML entities is currently recognized.

## Author

Generated automatically by Doxygen for wget2 from the source code.
