Пример #1
0
XMLElement XMLTree::getRootElement() const {
#ifdef PUGIXML
    return XMLElement(docPtr.first_child());
#else
    return XMLElement(xmlDocGetRootElement(docPtr));
#endif
}
Пример #2
0
    void XMLNodeList::setElementAtPosition(double index, const XMLNodeList & list)
    {
        if (list.getSize() && list.getRealNode() != parent)
        {
            int pos = (int)index;

            if (index < 1)
            {
                pos = 1;
            }
            else if (index > size)
            {
                pos = size++;
            }
            else if ((int)index != index)
            {
                pos++;
            }

            setElementAtPosition(index, XMLElement(doc, list.getRealNode()));
            for (xmlNode * cur = list.getRealNode()->next; cur; cur = cur->next)
            {
                setElementAtPosition((double)(pos++) + 0.5, XMLElement(doc, cur));
            }
        }
    }
Пример #3
0
XMLElement XMLElement::GetParent() const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    return XMLElement(file_, node.parent().internal_object());
}
Пример #4
0
XMLElement XMLElement::SelectSingle(const ea::string& query, pugi::xpath_variable_set* variables) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xpath_node result = node.select_single_node(query.c_str(), variables);
    return XMLElement(file_, nullptr, &result, 0);
}
Пример #5
0
XMLElement XMLElement::SelectSinglePrepared(const XPathQuery& query) const
{
    if (!file_ || (!node_ && !xpathNode_ && !query.GetXPathQuery()))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xpath_node result = node.select_single_node(*query.GetXPathQuery());
    return XMLElement(file_, nullptr, &result, 0);
}
Пример #6
0
XMLElement XMLElement::CreateChild(const char* name)
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    pugi::xml_node child = const_cast<pugi::xml_node&>(node).append_child(name);
    return XMLElement(file_, child.internal_object());
}
Пример #7
0
XMLElement XMLElement::GetChild(const char* name) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!String::CStringLength(name))
        return XMLElement(file_, node.first_child().internal_object());
    else
        return XMLElement(file_, node.child(name).internal_object());
}
Пример #8
0
XMLElement XMLElement::GetNext(const char* name) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!CStringLength(name))
        return XMLElement(file_, node.next_sibling().internal_object());
    else
        return XMLElement(file_, node.next_sibling(name).internal_object());
}
Пример #9
0
XMLElement XMLFile::GetRoot(const String& name)
{
    pugi::xml_node root = document_->first_child();
    if (root.empty())
        return XMLElement();
    
    if (!name.Empty() && name != root.name())
        return XMLElement();
    else
        return XMLElement(this, root.internal_object());
}
Пример #10
0
XMLElement XMLElement::NextResult() const
{
    if (!xpathResultSet_ || !xpathNode_)
        return XMLElement();

    return xpathResultSet_->operator [](++xpathResultIndex_);
}
Пример #11
0
XMLElement XPathResultSet::operator[](unsigned index) const
{
    if (!resultSet_)
        LOGERRORF("Could not return result at index: %u. Most probably this is caused by the XPathResultSet not being stored in a lhs variable.", index);

    return resultSet_ && index < Size() ? XMLElement(file_, this, &resultSet_->operator [](index), index) : XMLElement();
}
Пример #12
0
std::istream& XMLDoc::ReadDoc(std::istream& is)
{
    root_node = XMLElement(); // clear doc contents
    s_element_stack.clear();  // clear this to start a fresh read
    s_curr_parsing_doc = this;  // indicate where to add elements
    std::string parse_str;
    std::string temp_str;
    while (is) {
        getline(is, temp_str);
        parse_str += temp_str + '\n';
    }
    parse(parse_str.c_str(), document);
    s_curr_parsing_doc = 0;
    return is;
}
Пример #13
0
    void XMLNodeList::setElementAtPosition(double index, const std::string & xmlCode)
    {
        std::string error;
        XMLDocument document = XMLDocument(xmlCode, false, &error);

        if (error.empty())
        {
            setElementAtPosition(index, document);
        }
        else
        {
            xmlNode *n = xmlNewText((xmlChar *) xmlCode.c_str());

            setElementAtPosition(index, XMLElement(doc, n));
        }
    }
Пример #14
0
void XMLElement::setChildren(const std::string & xmlCode) const
{
    std::string error;
    XMLDocument document = XMLDocument(xmlCode, false, &error);

    if (error.empty())
    {
        setChildren(*document.getRoot());
    }
    else
    {
        xmlNode *n = xmlNewText((xmlChar *) xmlCode.c_str());

        setChildren(XMLElement(doc, n));
    }
}
Пример #15
0
XMLElement XMLElement::fromQString(const QString &str) {
    QStringList sections = str.split( ' ');
    QString tagname = sections[0];
    XMLElement e(tagname.latin1());

    sections.pop_front();
    // Loop over the remaining strings which are attributes="values"
    if(sections.count()) {
        const int sectionsCount = sections.count();
        for(int i = 0; i < sectionsCount; ++i) {
            QStringList list = sections[i].split( '=');
            if(list.count() != 2) {
                std::cerr << "XMLElement::fromQString: Cannot convert list: " << list.join("|") << ". `" << str << "' is not in valid format.\n";
                return XMLElement(" ");
            }
            e.setAttribute(list[0], list[1].left(list[1].length() - 1).right(list[1].length() -2));
        }
    }
    return e;
}
Пример #16
0
XMLElement XMLNode::toElement() const
{
	return XMLElement(*this);
}
Пример #17
0
XMLElement XMLFile::CreateRoot(const String& name)
{
    document_->reset();
    pugi::xml_node root = document_->append_child(name.CString());
    return XMLElement(this, root.internal_object());
}
Пример #18
0
XMLDoc::XMLDoc(const std::string& root_tag/*= "XMLDoc"*/) :
    root_node(XMLElement(root_tag, true))
{}
Пример #19
0
XMLDoc::XMLDoc(const std::istream& is) :
    root_node(XMLElement())
{}
Пример #20
0
void XMLDoc::SetElemName(const char* first, const char* last)
{ s_temp_elem = XMLElement(std::string(first, last)); }
Пример #21
0
 XMLElement findElementById(svg_string_t const & id)
 {
   std::pair<element_by_id_t::iterator, bool> ins = element_by_id_.insert(element_by_id_t::value_type(id, XMLElement()));
   if (ins.second)
     ins.first->second = FindChildElementById(getRoot(), id);
   return ins.first->second;
 }
Пример #22
0
void XMLElement::AppendChild(const std::string& tag)
{ m_children.push_back(XMLElement(tag)); }