Ejemplo n.º 1
0
bool
ZXmlParser::_add_before( IXMLDOMNodePtr newNode )
{
   if ( IsRoot( ) )
   {
      m_LastError = "ZXmlParser::_add_before( )   : Can't add node at same level that the root node";
      return( false );
   }

   // Create Reference Node for the Insertion
   IXMLDOMNodePtr pParent;
   m_CurrentNode->get_parentNode( &pParent );
   _variant_t NodeRef = (IUnknown *) m_CurrentNode;


   // Attach the Node to the document
   if ( m_CurrentNode )
          newNode = pParent->insertBefore( newNode, NodeRef );
   else
   if ( m_pDocRoot )
      newNode = m_pDocRoot->insertBefore( newNode, NodeRef );
   else
   {
      m_pDocRoot = newNode;
      m_plDomDocument->documentElement = m_pDocRoot;
   }

   // Update Current Node (cast operation)
   m_CurrentNode = newNode;

   // Update information for this Node
   GrabNodeInformation( m_CurrentNode );

   return( true );
}
Ejemplo n.º 2
0
bool
ZXmlParser::_add_after( IXMLDOMNodePtr newNode )
{
   // If m_CurrentNode->NextSibling == NULL then must call AddLastChildNode on Parent Node
   // Because we can't use InsertBefore on a NULL Reference ;o )
   //
   // We are sure that a Parent node exist because before we control that we aren't not on root node.
   if ( m_CurrentNode->nextSibling == NULL )
   {
      // Get Parent Node
      IXMLDOMNodePtr pParent;
      m_CurrentNode->get_parentNode( &pParent );

      // Set Parent node as Current Node
      m_CurrentNode = pParent;
      GrabNodeInformation( pParent );

      // Add Node as Last Child Node
      return( AddLastChildNode( m_Name ) );
   }

   // Create Reference Node for the Insertion
   IXMLDOMNodePtr pParent;
   m_CurrentNode->get_parentNode( &pParent );
   _variant_t NodeRef = (IUnknown *) m_CurrentNode->nextSibling;

   // Attach the Node to the document
   if ( m_CurrentNode )
      newNode = pParent->insertBefore( newNode, NodeRef );
   else
   if ( m_pDocRoot )
      newNode = m_pDocRoot->insertBefore( newNode, NodeRef );
   else
   {
      m_pDocRoot = newNode;
      m_plDomDocument->documentElement = m_pDocRoot;
   }

   // Update Current Node (cast operation)
   m_CurrentNode = newNode;

   // Update information for this Node
   GrabNodeInformation( m_CurrentNode );

   return( true );
}