Example #1
0
	void DomElement::set_child_string_ns(const DomString &namespace_uri, const DomString &qualified_name, const DomString &value)
	{
		DomString local_name;
		DomString::size_type pos = qualified_name.find(L':');
		if (pos != DomString::npos)
			local_name = qualified_name.substr(pos + 1);
		else
			local_name = qualified_name;

		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);
		}

		DomText dom_text = get_owner_document().create_text_node(value);
		if (element.get_first_child().is_text())
		{
			DomNode temp_domnode = element.get_first_child();
			replace_child(dom_text, temp_domnode);
		}
		else
		{
			element.append_child(dom_text);
		}
	}
Example #2
0
	DomString DomElement::get_child_string_ns(const DomString &namespace_uri, const DomString &local_name, const DomString &default_value) const
	{
		DomElement element = named_item_ns(namespace_uri, local_name).to_element();
		if (!element.is_null() && element.get_first_child().is_text())
			return element.get_first_child().to_text().get_node_value();
		else
			return default_value;
	}
Example #3
0
void Project::load_item_children(ProjectItem *item, DomElement dom_items)
{
	DomElement cur = dom_items.get_first_child_element();
	while (!cur.is_null())
	{
		item->add(load_item(cur));
		cur = cur.get_next_sibling_element();
	}
}
Example #4
0
	void DomElement::set_child_string(const DomString &name, const DomString &value)
	{
		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())
		{
			DomNode my_child = element.get_first_child();
			element.remove_child(my_child);
		}

		DomText dom_text = get_owner_document().create_text_node(value);
		element.append_child(dom_text);
	}
Example #5
0
	DomString DomNode::find_prefix(const DomString &namespace_uri) const
	{
		DomElement cur = to_element();
		while (!cur.is_null())
		{
			DomNamedNodeMap attributes = cur.get_attributes();
			int size = attributes.get_length();
			for (int index = 0; index < size; index++)
			{
				DomNode attribute = attributes.item(index);
				if (attribute.get_prefix() == "xmlns" &&
					attribute.get_node_value() == namespace_uri)
				{
					return attribute.get_local_name();
				}
			}
			cur = cur.get_parent_node().to_element();
		}
		return DomString();
	}