Exemplo n.º 1
0
void CL_DomElement::set_child_string_ns(const CL_DomString &namespace_uri, const CL_DomString &qualified_name, const CL_DomString &value)
{
	CL_DomString local_name;
	CL_DomString::size_type pos = qualified_name.find(L':');
	if (pos != CL_DomString::npos)
		local_name = qualified_name.substr(pos+1);
	else
		local_name = qualified_name;

	CL_DomElement element = named_item_ns(namespace_uri, local_name).to_element();
	if (element.is_null())
	{
		element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
		append_child(element);
	}

	CL_DomText dom_text = get_owner_document().create_text_node(value);
	if (element.get_first_child().is_text())
	{
		CL_DomNode temp_domnode = element.get_first_child();
		replace_child(dom_text, temp_domnode);
	}
	else
	{
		element.append_child(dom_text);
	}
}
Exemplo n.º 2
0
void CL_DomElement::set_child_string(const CL_DomString &name, const CL_DomString &value)
{
	CL_DomElement element = named_item(name).to_element();
	if (element.is_null())
	{
		element = get_owner_document().create_element(name);
		append_child(element);
	}

	while (!element.get_first_child().is_null())
	{
		CL_DomNode my_child = element.get_first_child();
		element.remove_child(my_child);
	}

	CL_DomText dom_text = get_owner_document().create_text_node(value);
	element.append_child(dom_text);
}