|
Arduino DLNA Server
|
Small utility to extract attributes from a start-tag in an XML fragment. More...
#include <XMLAttributeParser.h>
Static Public Member Functions | |
| static bool | extractAttribute (const char *xml, const char *tagName, const char *attrName, char *outBuf, size_t bufSize) |
| Find the first occurrence of a start-tag and extract an attribute value. | |
| static bool | extractAttributeToken (const char *xml, const char *tagName, const char *attrName, int n, char *outBuf, size_t bufSize) |
Extract the nth (1-based) colon-separated token from an attribute value located on the first occurrence of tagName. | |
Small utility to extract attributes from a start-tag in an XML fragment.
This helper does not attempt full XML validation but is suitable for small embedded parsing tasks (for example: extracting the protocolInfo attribute from a DIDL-Lite <res ...> element).
|
inlinestatic |
Find the first occurrence of a start-tag and extract an attribute value.
This searches for the first occurrence of tagName (for example "<res") in xml and looks for the attribute named attrName inside that tag. If found, the attribute value (the text between the surrounding double quotes) is copied into outBuf (null-terminated).
| xml | Pointer to a null-terminated XML fragment to search. |
| tagName | Start-tag to locate (e.g. "<res"). |
| attrName | Attribute name to extract (e.g. "protocolInfo" or "protocolInfo="). The function expects a double-quoted value (attrName="..."). |
| outBuf | Destination buffer where the extracted value will be written (null-terminated). Must be non-null. |
| bufSize | Size of outBuf in bytes; if the attribute value is longer than bufSize - 1 it will be truncated. |
outBuf, false otherwise (invalid inputs, tag/attribute not found, malformed tag).
|
inlinestatic |
Extract the nth (1-based) colon-separated token from an attribute value located on the first occurrence of tagName.
This helper locates tagName (for example "<res") and extracts the value of attrName (expects a double-quoted value). The attribute value is split on ':' characters and the nth token (1-based) is copied into outBuf.
| xml | Pointer to a null-terminated XML fragment to search. |
| tagName | Start-tag to locate (e.g. "<res"). Only the first occurrence is scanned. |
| attrName | Attribute name to extract (with or without trailing '='). The function expects a double-quoted value. |
| n | 1-based index of the colon-separated token to return. |
| outBuf | Destination buffer where the token will be written (null-terminated). Must be non-null. |
| bufSize | Size of outBuf in bytes; if the token is longer than bufSize - 1 it will be truncated. |
outBuf, false otherwise (invalid inputs, tag/attribute not found, index out of range).Example: attrName = "protocolInfo" (or "protocolInfo="), n = 3 protocolInfo="http-get:*:audio/mpeg:*" -> returns "audio/mpeg".