xml_new_element_with_text(struct xml_node *parent, const tchar *name,
const tchar *text);
-struct xml_node *
-xml_new_attrib(struct xml_node *parent, const tchar *name, const tchar *value);
-
void
xml_add_child(struct xml_node *parent, struct xml_node *child);
/*****************************************************************************/
int
-xml_parse_document(const tchar *p, struct xml_node **doc_ret);
+xml_parse_document(const tchar *raw_doc, struct xml_node **doc_ret);
/*****************************************************************************/
* or empty) an element containing text.
*/
static int
-xml_set_text_by_path(struct xml_node *root, const tchar *path, const tchar *text)
+xml_set_text_by_path(struct xml_node *root, const tchar *path,
+ const tchar *text)
{
int ret;
struct xml_node *element;
return xml_element_set_text(element, text);
} else {
/* Remove */
- element = xml_get_element_by_path(root, path);
- if (element)
- xml_free_node(element);
+ xml_free_node(xml_get_element_by_path(root, path));
return 0;
}
}
if (*p == '/') {
/* Closing an empty element tag */
p++;
- CHECK(*p == '>');
- p++;
} else {
/* Closing the start tag */
CHECK(*p == '>');
CHECK(!tstrncmp(p, name_start, name_len));
p += name_len;
skip_whitespace(&p);
- CHECK(*p == '>');
- p++;
}
+ CHECK(*p == '>');
+ p++;
*pp = p;
if (element_ret)
*element_ret = element;
}
static void
-xml_write_element(struct xml_node *node, struct xml_out_buf *buf)
+xml_write_element(struct xml_node *element, struct xml_out_buf *buf)
{
struct xml_node *child;
/* Write the start tag. */
xml_puts(buf, T("<"));
- xml_puts(buf, node->name);
- xml_node_for_each_child(node, child) {
+ xml_puts(buf, element->name);
+ xml_node_for_each_child(element, child) {
if (child->type == XML_ATTRIBUTE_NODE) {
xml_puts(buf, T(" "));
xml_puts(buf, child->name);
xml_puts(buf, T(">"));
/* Write the contents. */
- xml_node_for_each_child(node, child) {
+ xml_node_for_each_child(element, child) {
if (child->type == XML_TEXT_NODE)
xml_escape_and_puts(buf, child->value);
else if (child->type == XML_ELEMENT_NODE)
/* Write the end tag. */
xml_puts(buf, T("</"));
- xml_puts(buf, node->name);
+ xml_puts(buf, element->name);
xml_puts(buf, T(">"));
}