Re: [xml] Getting element content non-recursively




Hi Daniel,

There is no notion in XML of parsing "fragment of a document", it's defined
only in terms of parsing a full document.

Yes, so what I am trying to do instead, is take one XML document that has
been parsed, and add its contents to a node of an existing XML document.

I'm apparently too jet-lag to fully understand what you are doing here,
sorry !

Well, my overall intention is to take a fragment of XML, and insert that
fragment including all children to an existing node of another document. As
that is not an operation that is inherently supported with XML, I am trying
to achieve the same effect by iterating over the nodes of the fragment in a
recursive fashion and adding each one to my target document. Thus at each
node I am doing something like: (pseudo code)

    Node* node = targetNode->make_new_element(sourceNode->get_name());
    node->set_content(sourceNode->get_content());
    for (iterator i = sourceNode ->attributes_begin();
        i != sourceNode ->attributes_end(); ++i)
    {
        node->add_attribute();
    }
    // now call this function recursively with any children of sourceNode

The call to get_content() above, is where the call is being made to
xmlNodeGetContent and what I want here is the text of just the current node
only, and not its children.

Thanks,
Caroline M.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]