HTML_NODE_ADD_ATTR(3)

NAME
html_node_add_attr - add attribute to a HTML node

SYNOPSIS

#include <slweb/html.h>

int html_node_add_attr(struct html_node *n, const char *attr, const char *val);

DESCRIPTION
The html_node_add_attr(3) function adds an attribute to a struct html_node object pointed to by n, previously returned by html_node_alloc(3) or html_node_add_child(3). attr is a null-terminated string with the name of the attribute. val is a null-terminated string with the value for the attribute. slweb allocates copies of the null-terminated strings defined by attr and val.

RETURN VALUE
On success, html_node_add_attr(3) returns zero. On failure, a negative integer is returned.

EXAMPLE
A struct html_node object with example as tag name, no value and name as its attribute with value john would be translated by the HTML serializer to:

    <example name="john"/>

ERRORS
No errors are defined.

SEE ALSO
html_node_alloc(3), html_node_free(3), html_node_set_value(3), html_node_set_value_unescaped(3), slweb_http(7).

COPYRIGHT
Copyright (C) 2023 Xavier Del Campo Romero.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.