コード例 #1
3
BOOL vmsMetalinkFile::ReadVerificationNode(IXMLDOMNode *pNode, vmsMetalinkFile_File *file)
{
	IXMLDOMNodeListPtr spNodeList;
	pNode->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	IXMLDOMNodePtr spItem;
	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"hash")
		{
			vmsMetalinkFile_File_Hash hash;
			if (ReadHashNode (spItem, &hash))
				file->vHashes.add (hash);
		}

		spItem = NULL;
	}

	return TRUE;
}
コード例 #2
0
BOOL vmsMetalinkFile::ReadResourcesNode(IXMLDOMNode *pNode, vmsMetalinkFile_File *file)
{
	IXMLDOMNodeListPtr spNodeList;
	pNode->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	IXMLDOMNodePtr spItem;
	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"url")
		{
			vmsMetalinkFile_File_Url url;
			if (ReadUrlNode (spItem, &url))
				file->vMirrors.add (url);
		}

		spItem = NULL;
	}

	return TRUE;
}
コード例 #3
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
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 );
}
コード例 #4
0
BOOL vmsMetalinkFile::ReadUrlNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Url *url)
{
	USES_CONVERSION;

	IXMLDOMNamedNodeMapPtr spAttrs;
	pNode->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;

	IXMLDOMNodePtr spType;
	spAttrs->getNamedItem (L"type", &spType);
	if (spType == NULL)
		return FALSE;

	COleVariant vt;
	spType->get_nodeValue (&vt);
	ASSERT (vt.vt == VT_BSTR);
	if (vt.vt == VT_BSTR)
		url->strProtocol = W2A (vt.bstrVal);
	
	CComBSTR bstrText;
	pNode->get_text (&bstrText);
	if (bstrText.Length () == 0)
		return FALSE;

	url->strUrl = W2A (bstrText);

	return TRUE;
}
コード例 #5
0
BOOL vmsMetalinkFile::ReadHashNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Hash *hash)
{
	USES_CONVERSION;

	IXMLDOMNamedNodeMapPtr spAttrs;
	pNode->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;

	IXMLDOMNodePtr spType;
	spAttrs->getNamedItem (L"type", &spType);
	if (spType == NULL)
		return FALSE;

	COleVariant vt;
	spType->get_nodeValue (&vt);
	ASSERT (vt.vt == VT_BSTR);
	if (vt.vt == VT_BSTR)
		hash->strAlgorithm = W2A (vt.bstrVal);
	
	CComBSTR bstrText;
	pNode->get_text (&bstrText);
	if (bstrText.Length () == 0)
		return FALSE;

	hash->strChecksum = W2A (bstrText);

	return TRUE;
}
コード例 #6
0
BOOL vmsMetalinkFile::ReadFilesNode(IXMLDOMNode *pFiles)
{
	IXMLDOMNodeListPtr spNodeList;
	pFiles->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	IXMLDOMNodePtr spItem;
	BOOL bHasOkFileNode = FALSE;

	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"file")
		{
			if (ReadFileNode (spItem))
				bHasOkFileNode = TRUE;
		}

		spItem = NULL;
	}

	return bHasOkFileNode;
}
コード例 #7
0
VARIANT XMLDoc::getVariant(const XMLNodePtr &node, const TCHAR *tagName, int instans) {
  VARIANT result;
  result.vt = NULL;

  if(node!=NULL) {
    int i=0;
    for(XMLNodePtr p = node->firstChild; p != NULL; p = p->nextSibling) {
      if(p->nodeType==NODE_ELEMENT &&
          _tcsicmp(((XMLElementPtr)p)->tagName,tagName) == 0 &&
          i++ == instans) {
        IXMLDOMNodeListPtr childList = p->childNodes;
        LONG length;
        childList->get_length(&length);
        for(int j = 0; j < length; j++) {
          IXMLDOMNodePtr item;
          childList->get_item(j, &item);
          DOMNodeType itemType;
          item->get_nodeType(&itemType);
          if(itemType == NODE_TEXT) {
            item->get_nodeValue(&result);
            return result;
          }
        }
        return result;
      }
    }
  }
  return result;
}
コード例 #8
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
bool
ZXmlParser::SetTextValue( LPCTSTR TextValue )
{
   // Nodes members
   // IXMLDOMElementPtr m_CurrentNode;        /* Global Member */
   IXMLDOMNodePtr newNode;

   // Find if a CHILD TEXT NODE exist or not
   if ( m_CurrentNode == NULL )
   {
      if ( m_pDocRoot )
         m_CurrentNode = m_pDocRoot;
      else
      {
         m_LastError = "ZXmlParser::SetTextValue( LPCTSTR )   : Can't set a Text on a NULL Node";
         return( false );
      }
   }

   if ( IsMSXML_Node( m_CurrentNode ) == NODE_CDATA_SECTION )
   {
     CComVariant sValue( TextValue );
     m_CurrentNode->put_nodeValue( sValue );

     return( true );
   }

   // Rq: a NODE_CDATA_SECTION can't have any childs
   if ( m_CurrentNode->hasChildNodes( ) )
   {
      IXMLDOMNodePtr pChild;
      for( pChild = m_CurrentNode->firstChild; pChild; pChild = pChild->nextSibling )
      {
         // Find it's a NODE TEXT
         if ( IsMSXML_Node( pChild ) == NODE_TEXT )
         {
            // A Text Node is found, Replace it now!!
            CComVariant sValue( TextValue );
            pChild->put_nodeValue( sValue );

            return( true );
         }
      }
   }

   // No previous Text was defined before, we can add it.
   if ( IsMSXML_Node( m_CurrentNode ) == NODE_ELEMENT )
   {
      // Create NODE TEXT type
      CComVariant vType( MSXML2::NODE_TEXT );

      // Create the node
      newNode = m_plDomDocument->createTextNode( TextValue );

      // Attach the Node to the document
      newNode = m_CurrentNode->appendChild( newNode );
   }

   return( true );
}
コード例 #9
0
ファイル: SkinClass.cpp プロジェクト: mengskysama/V8
BOOL CSkinClass::LoadPropertyFromXml(IXMLDOMNodePtr ptrNode)
{
    IXMLDOMNodePtr pNode = NULL;
    IXMLDOMNamedNodeMapPtr pNamedNodeMap = NULL;
    DOMNodeType nodeType = NODE_INVALID;

    long len = 0;
    BOOL allSuc = TRUE;
    ptrNode->get_attributes(&pNamedNodeMap);
    pNamedNodeMap->get_length(&len);
    for (int i=0; i<len; i++){
        pNamedNodeMap->get_item(i, &pNode);
        pNode->get_nodeType(&nodeType);
        if (nodeType != NODE_ATTRIBUTE)
            continue;

        CComBSTR bstrName;
        CComVariant varValue;
        pNode->get_nodeName(&bstrName);
        pNode->get_nodeValue(&varValue);
        if (varValue.vt != VT_BSTR)
            continue;

        CString strName = bstrName;
        CString strValue = varValue.bstrVal;
        if (strName.CompareNoCase(_T("name")) != 0) {
            SetProp(strName, strValue);
        } else {
            ASSERT(m_strClassName.IsEmpty());
            SetClassName(strValue);
        }
    }

    return allSuc;
}
コード例 #10
0
ファイル: RSS.cpp プロジェクト: kragen/mod_pubsub
_bstr_t GetAttributeValue(IXMLDOMNodePtr node, const _bstr_t& name)
{
	IXMLDOMNodePtr attr = GetAttributeNode(node, name);

	if (attr == NULL)
		return _bstr_t();

	return attr->GetnodeValue();
}
コード例 #11
0
BOOL vmsMetalinkFile::Parse(LPCSTR pszFile)
{
	USES_CONVERSION;

	IXMLDOMDocumentPtr spXML;
	IXMLDOMNodePtr spNode;

	spXML.CreateInstance (__uuidof (DOMDocument));

	if (spXML == NULL)
		return FALSE;

	spXML->put_async (FALSE);

	VARIANT_BOOL bRes;
	spXML->load (COleVariant (pszFile), &bRes);
	if (bRes == FALSE)
		return FALSE;

	spXML->selectSingleNode (L"metalink", &spNode);
	if (spNode == NULL)
		return FALSE;

	IXMLDOMNodeListPtr spNodeList;
	spNode->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	IXMLDOMNodePtr spItem;

	BOOL bHasOkFilesNode = FALSE;

	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"description")
		{
			CComBSTR bstrText;
			spItem->get_text (&bstrText);
			m_strDescription = W2A (bstrText);
		}

		else if (bstrName == L"files")
		{
			if (ReadFilesNode (spItem))
				bHasOkFilesNode = TRUE;
		}

		spItem = NULL;
	}

	return bHasOkFilesNode;
}
コード例 #12
0
ファイル: RSS.cpp プロジェクト: kragen/mod_pubsub
_bstr_t GetPathValue(IXMLDOMNodePtr node, const _bstr_t& path)
{
	if (node == NULL)
		return _bstr_t();
	
	IXMLDOMNodePtr n = node->selectSingleNode(path);
	
	if (n == NULL)
		return _bstr_t();

	return n->Gettext();
}
コード例 #13
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
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 );
}
コード例 #14
0
void CXMLTree::InsetXMLNode(MSXML2::IXMLDOMNodePtr iNode, HTREEITEM hParentItem)
{
	IXMLDOMNodeListPtr iChildren = iNode->childNodes;


	IXMLDOMNodePtr iChild = NULL;

	while ((iChild = iChildren->nextNode()) != NULL)
	{
		CString s((BSTR) iChild->nodeName);

		HTREEITEM i = InsertItem(s, hParentItem);
		iChild.AddRef();
		SetItemData(i, (DWORD) (IXMLDOMNode *) iChild);
	

		//rekurze
		InsetXMLNode(iChild, i);
	}

}
コード例 #15
0
ファイル: RSS.cpp プロジェクト: kragen/mod_pubsub
IXMLDOMNodePtr GetAttributeNode(IXMLDOMNodePtr node, const _bstr_t& name)
{
	if (node == NULL)
		return NULL;

	IXMLDOMNamedNodeMapPtr attributes = node->Getattributes();
	if (attributes == NULL)
		return NULL;

	IXMLDOMNodePtr att = attributes->getNamedItem(name);
	return att;
}
コード例 #16
0
/**************************************************************************
 * written by moonknit
 *
 * @history
 * created 2005-10-31
 *
 * @Description
 * XML의 attribute나 element text를 변경 또는 추가한다.
 * update or insert item text
 *
 * @Parameters
 * (in _bstr_t) sname - search name
 * (in/out CEzXMLParser*) parser - 검색할 xml 클래스
 * (in _bstr_t) text - 변경할 내용 
 * (in int) type - 변경할 대상의 속성
 * 0 : attribute
 * 1 : element text
 * (in IXMLDOMNodePtr) node - 검색 root node
 *
 * @Returns
 * (BOOL)
 * 0 : failed
 * 1 : updated
 * 2 : inserted
 **************************************************************************/
int SetNamedNodeText(_bstr_t sname, CEzXMLParser* parser, _bstr_t text, int type, IXMLDOMNodePtr node)
{
	if(!parser) return 0;

	if(type == 0)
	{
		IXMLDOMNodePtr nodeptr = NULL;
		nodeptr = node->attributes->getNamedItem(sname);
		if(nodeptr == NULL)
		{
			IXMLDOMAttributePtr attptr = parser->CreateAttribute(sname, text);
			if(attptr == NULL) return 0;

			// create attribute
			node->attributes->setNamedItem(attptr);

			return 2;
		}
		else
		{
			// update attribute
			nodeptr->text = text;
		}
	}
	else
	{
		IXMLDOMNodeListPtr listptr;
		listptr = parser->SearchNodes(node, sname);
		
		if(listptr == NULL || listptr->length == 0)
		{
			// create element
			IXMLDOMElementPtr elptr = parser->CreateElement(sname);

			if(elptr == NULL)
				return 0;

			elptr->text = text;
			if(node->appendChild(elptr) == NULL)
				return 0;

			return 2;
		}
		else
		{
			// update element text
			listptr->item[0]->text = text;
		}
	}

	return 1;
}
コード例 #17
0
BOOL vmsVideoSiteHtmlCodeParser::Parse_Further_MySpace(LPCSTR pszHtml)
{
	USES_CONVERSION;
	IXMLDOMDocumentPtr spXML;
	IXMLDOMNodePtr spNode, spNode2;

	while (*pszHtml && *pszHtml != '<')
		pszHtml++;

	spXML.CreateInstance (__uuidof (DOMDocument));

	if (spXML == NULL)
		return FALSE;

	spXML->put_async (FALSE);

	VARIANT_BOOL bRes;
	spXML->loadXML (A2W (pszHtml), &bRes);
	if (bRes == FALSE)
		return FALSE;

	spXML->selectSingleNode (L"rss", &spNode);
	if (spNode == NULL)
		return FALSE;

	spNode->selectSingleNode (L"channel", &spNode2);
	if (spNode2 == NULL)
		return FALSE;

	spNode = NULL;
	spNode2->selectSingleNode (L"item", &spNode);
	if (spNode == NULL)
		return FALSE;

	spNode2 = NULL;
	spNode->selectSingleNode (L"title", &spNode2);
	if (spNode2 == NULL)
		return FALSE;

	CComBSTR bstrTitle;
	spNode2->get_text (&bstrTitle);

	spNode2 = NULL;
	spNode->selectSingleNode (L"media:content", &spNode2);
	if (spNode2 == NULL)
		return FALSE;
	IXMLDOMNamedNodeMapPtr spAttrs;
	spNode2->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;
	IXMLDOMNodePtr spUrlValue;
	spAttrs->getNamedItem (L"url", &spUrlValue);
	if (spUrlValue == NULL)
		return FALSE;
	COleVariant vtUrl;
	spUrlValue->get_nodeValue (&vtUrl);
	ASSERT (vtUrl.vt == VT_BSTR);
	if (vtUrl.vt != VT_BSTR)
		return FALSE;

	m_strVideoTitle = W2A (bstrTitle);
	fsDecodeHtmlText (m_strVideoTitle);
	m_strVideoUrl   = W2A (vtUrl.bstrVal);
	m_strVideoType  = (LPCSTR)m_strVideoUrl + m_strVideoUrl.GetLength () - 3;
	m_bDirectLink	= TRUE;

	return TRUE;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: tomorrow56/VS2010
bool GetXmlValue(	const IXMLDOMDocumentPtr&	pXMLDOMDocument,
					const CComBSTR&				bstrTagName,
					const CComBSTR&				bstrAttributeName,
					std::vector<CComBSTR>&		rvbstrValue )
{
	// アウトプットの初期化
	rvbstrValue.clear();

	// インプットのチェック
	if( 0 == bstrTagName.Length() )
	{
		return false;
	}

	HRESULT hResult;

	// タグ名のノードリストの取得
	IXMLDOMNodeListPtr pXMLDOMNodeList = NULL;
	hResult = pXMLDOMDocument->getElementsByTagName( bstrTagName, &pXMLDOMNodeList );
	if( FAILED(hResult) || NULL == pXMLDOMNodeList )
	{
		assert( !"タグ名のノードリストの取得に失敗" );
		return false;
	}
	// ノードリストのノードの数の取得
	long lCountNode = 0;
	hResult = pXMLDOMNodeList->get_length( &lCountNode );
	if( FAILED(hResult) )
	{
		assert( !"ノードリストのノードの数の取得に失敗" );
		return false;
	}
	// ノードリストのノード一つずつ処理
	for( int i = 0; i < lCountNode; ++i )
	{
		// ノードリストのうちの一つのノードの取得
		IXMLDOMNodePtr pXMLDOMNode = NULL;
		hResult = pXMLDOMNodeList->get_item( i, &pXMLDOMNode );
		if( FAILED(hResult) )
		{
			assert( !"ノードリストのうちの一つのノードの取得に失敗" );
			return false; 
		}

		// ノードタイプの取得
		DOMNodeType eNodeType;
		hResult = pXMLDOMNode->get_nodeType( &eNodeType );
		if( FAILED(hResult) )
		{
			assert( !"ノードタイプの取得に失敗" );
			return false; 
		}
		if( NODE_ELEMENT != eNodeType )
		{
			assert( !"ノードタイプがエレメントでないのはおかしい" );
			return false;
		}
		// エレメント型への変換
		IXMLDOMElementPtr pXMLDOMElement = NULL;
		hResult = pXMLDOMNode->QueryInterface( IID_IXMLDOMElement, (void**)&pXMLDOMElement );	// スマートポインタ型を利用しているので、pXMLDOMElement = pXMLDOMNode; でも良い。
		if( FAILED(hResult) || NULL == pXMLDOMElement )
		{
			assert( !"エレメント型への変換に失敗" );
			return false;
		}

		// 属性値の取得か、データ値の取得か
		if( bstrAttributeName.Length() )
		{	// 属性値の取得
			IXMLDOMAttribute* pAttributeNode = NULL;
			CComVariant varValue;
			hResult = pXMLDOMElement->getAttribute( bstrAttributeName, &varValue ); 
			if( SUCCEEDED(hResult) && VT_BSTR == varValue.vt )
			{
				rvbstrValue.push_back( varValue.bstrVal );
			}
		}
		else
		{	// データ値の取得
			CComBSTR bstrText;
			hResult = pXMLDOMElement->get_text( &bstrText );
			if( SUCCEEDED(hResult) )
			{
				rvbstrValue.push_back( bstrText );
			}
		}
	}

	return true;
}
コード例 #19
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
// ***************************
// ** Header XML Management **
// ***************************
bool
ZXmlParser::SetHeader( LPCTSTR header, LPCTSTR name, LPCTSTR value )
{
   m_LastError = m_ok;
   bool bEmptyXml = false;

   CString strHeader = header;
   CString strName = name;
   CString strValue = value;

   BSTR bstr;
   CString cstr, cstr2;

   IXMLDOMNodePtr pChild = NULL;           // Working node
   pChild = m_plDomDocument->firstChild;   // Start at first document child

   if ( pChild == NULL )
      bEmptyXml = true;

   while ( pChild )
   {
      if ( pChild == m_pDocRoot )
      {
         // Root document reach, it's done, the processing node wasn't found
         break;
      }

      if ( pChild->nodeType != NODE_PROCESSING_INSTRUCTION )
      {
         pChild = pChild->nextSibling;    // Go to Next Processing instruction node
         continue;
      }


      pChild->get_baseName( &bstr );
      cstr = bstr;
      if ( cstr == header )
      {
         // Correct header, check the correct property
         pChild->get_text( &bstr );
         cstr = bstr;

         int index = cstr.Find( name, 0 );
         if ( index == -1 )
         {
            // The property doesn't exist on this processing instruction" );

            // Assume correct constraint about "xml" processing instruction
            {
               // must have version="xxx" in first
               // must have standalone="xxx" in last if exist
               cstr2.Empty( );
               int standalone_index = cstr.Find( "standalone", 0 );
               if ( standalone_index != -1 )
               {
                  cstr2 = cstr.Right(  cstr.GetLength( ) - standalone_index + 1 );
                  cstr  = cstr.Left( standalone_index );
               }

               int version_index = cstr.Find( "version", 0 );
               if ( version_index == -1 && strHeader == "xml" )
               {
                  CString strTemp = cstr;
                  cstr = "version=\"1.0\" ";
                  cstr += strTemp;
               }

               if ( strName != "version" )
                  cstr += " " + strName + "=\"" + strValue + "\" " + cstr2;
               else
                  cstr += cstr2;
            }

            // Create the new Processing Instruction node
            HRESULT hr;
            IXMLDOMProcessingInstruction *pIXMLDOMPInstr = NULL;
            hr = m_plDomDocument->raw_createProcessingInstruction( _bstr_t( strHeader ), _bstr_t( cstr ), &pIXMLDOMPInstr );

            if ( SUCCEEDED( hr ) )
            {
               // We succes the creation of the processing instruction
               // Replace the node
               m_plDomDocument->replaceChild( pIXMLDOMPInstr, pChild );
            }
            else
            {
               // Arf, i fails the creation, grrr, again
               m_LastError="ZXmlParser::SetHeader( ) : Can't create the new processing instruction node";
               return( false );
            }
            return( true );
         }
         else
         {
            // The processing instruction node exists, must change it's value!!
            int start, end;
            start = cstr.Find( '"', index );
            if ( start == -1 )
            {
               m_LastError = "ZXmlParser::SetHeader( ) : bad value structure";
               return( false );
            }

            end = cstr.Find( '"', start + 1 );
            if ( end == -1 )
            {
               m_LastError = "ZXmlParser::SetHeader( ) : bad value structure";
               return( false );
            }

            cstr2 = cstr.Mid( 0, start + 1 ) + value + cstr.Mid( end, cstr.GetLength( ) - end );

            IXMLDOMNodePtr m_lpNode = NULL;
            IXMLDOMProcessingInstruction *pIXMLDOMPInstr = NULL;
            HRESULT hr;

            hr = m_plDomDocument->raw_createProcessingInstruction( _bstr_t( strHeader ), _bstr_t( cstr2 ), &pIXMLDOMPInstr );

            if ( SUCCEEDED( hr ) )
            {
               // We succeeded in the creation of the processing instruction
               // Replace the node
               m_plDomDocument->replaceChild( pIXMLDOMPInstr, pChild );
            }
            else
            {
               m_LastError="ZXmlParser::SetHeader( ) : Can't create the new processing instruction node";
               return( false );
            }

            return( true );
        }
     }

     pChild = pChild->nextSibling;   // next processing instruction node
   }

   // No processing node for our header
   {
      if ( strName != "version" && strHeader == "xml" )
         cstr = "version=\"1.0\" " + strName + "=\"" + strValue + "\"";
      else
         cstr = strName + "=\"" + strValue + "\"";

      IXMLDOMNodePtr m_lpNode = NULL;
      IXMLDOMProcessingInstruction *pIXMLDOMPInstr = NULL;
      HRESULT hr;

      hr = m_plDomDocument->raw_createProcessingInstruction( _bstr_t( strHeader ), _bstr_t( cstr ), &pIXMLDOMPInstr );
      if ( SUCCEEDED( hr ) )
      {
         if ( !bEmptyXml )
         {
            _variant_t NodeRef = (IUnknown *) m_pDocRoot;
            m_lpNode = NULL;
            m_lpNode = m_plDomDocument->insertBefore( pIXMLDOMPInstr, NodeRef );
            if ( m_lpNode == NULL )
               m_LastError = "PARSER_XML::SetHeader( ) : Can't insert Processing node after the root document";

            return( m_lpNode != NULL );
         }
         else
         {
            m_lpNode = NULL;
            m_lpNode = m_plDomDocument->appendChild( pIXMLDOMPInstr );
            if ( m_lpNode == NULL )
               m_LastError = "PARSER_XML::SetHeader( ) : Can't insert Processing node in the empty document";

            return( m_lpNode != NULL );
         }
      }

      m_LastError = "PARSER_XML::SetHeader( ) : Can't create new Processing node";
      return( false );
   }
}
コード例 #20
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
bool
ZXmlParser::GetHeader( LPCTSTR header, LPCTSTR name, CString& res )
{
   m_LastError = m_ok;

   IXMLDOMNodePtr pChild;                  // working node
   res.Empty( );

   pChild = m_plDomDocument;
   pChild = m_plDomDocument->firstChild;   // start at first document child

   if ( pChild == NULL )
   {
      m_LastError = "ZXmlParser::Get_Header( ) : The XML Document is a null pointer";
      return( false );
   }

   while( pChild )
   {
      if ( pChild->nodeType != NODE_PROCESSING_INSTRUCTION )
         break;

      BSTR bstr;
      CString cstr;

      pChild->get_baseName( &bstr );
      cstr = bstr;
      if ( cstr == header )
      {
         // Correct header, check the correct property
         pChild->get_text( &bstr );
         cstr = bstr;

         int index = cstr.Find( name, 0 );
         if ( index == -1 )
            return( false );

         int start, end;
         start = cstr.Find( '"', index );
         if ( start == -1 )
         {
            m_LastError = "ZXmlParser::Get_Header( ) : bad value structure";
            return( false );
         }

         end = cstr.Find( '"', start + 1 );
         if ( end == -1 )
         {
            m_LastError = "ZXmlParser::Get_Header( ) : bad value structure";
            return( false );
         }

         res = cstr.Mid( start + 1, end - start - 1 );
         return( true );
      }

      pChild = pChild->nextSibling;   // next Processing instruction node
   }

   return( false );
}
コード例 #21
0
ファイル: XML_PARSER.cpp プロジェクト: DeegC/10d
void
ZXmlParser::GrabNodeInformation( IXMLDOMNodePtr pChild )
{
   if ( IsMSXML_Node( pChild ) == NODE_ELEMENT )
   {
      // It's a node

      // Tag Update
      m_Tag.Format( "<%s>", (const char *)( pChild->nodeName ) );
      m_Name = (const char *)( pChild->nodeName );

      // TextField no significant value
      m_TextField.Empty( );

      // Update Attribute List
      m_AttribNames.RemoveAll( );
      m_AttribValues.RemoveAll( );

      IXMLDOMNamedNodeMapPtr pAttribs = pChild->Getattributes( );
      if ( pAttribs )
      {
         long nAttriCnt = pAttribs->Getlength( );

         // Iterate over the attributes
         for( int i=0; i<nAttriCnt; ++i )
         {
            IXMLDOMNodePtr pAttrib = pAttribs->Getitem( i );
            if ( pAttrib )
            {
               CString cs = ( const char * ) pAttrib->GetnodeName( );
               m_AttribNames.Add( cs );

               _variant_t vVal = pAttrib->GetnodeValue (  );
               cs = ( const char * ) _bstr_t( vVal );
               m_AttribValues.Add(  cs );
            }
         }
      }
   }
   else
   if ( IsMSXML_Node( pChild ) == NODE_TEXT )
   {
      // Tag is #TEXT#
      m_Tag.Empty( );
      m_Tag = "<#TEXT#>";
      m_Name.Empty( );
      m_Name = "#TEXT#";

      // TextField Update
      m_TextField = (const char *)( pChild->text );

      // Update Attribute List have no means
      m_AttribNames.RemoveAll( );
      m_AttribValues.RemoveAll( );
   }
   else
   if ( IsMSXML_Node( pChild ) == NODE_CDATA_SECTION )
   {
      // Tag is #CDATA#
      m_Tag.Empty( );
      m_Tag = "<#CDATA#>";
      m_Name.Empty( );
      m_Name = "#CDATA#";

      // TextField Update
      m_TextField = (const char *)( pChild->text );

      // Update Attribute List have no means
      m_AttribNames.RemoveAll( );
      m_AttribValues.RemoveAll( );
   }
   else
   if ( IsMSXML_Node( pChild ) == NODE_PROCESSING_INSTRUCTION )
   {
      // Do nothing here
   }

   return;
}
コード例 #22
0
BOOL vmsMetalinkFile::ReadFileNode(IXMLDOMNode *pFile)
{
	USES_CONVERSION;

	IXMLDOMNodeListPtr spNodeList;
	pFile->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	vmsMetalinkFile_File file;

	IXMLDOMNamedNodeMapPtr spAttrs;
	pFile->get_attributes (&spAttrs);
	if (spAttrs != NULL)
	{
		IXMLDOMNodePtr spFileName;
		spAttrs->getNamedItem (L"name", &spFileName);
		if (spFileName != NULL)
		{
			COleVariant vt;
			spFileName->get_nodeValue (&vt);
			ASSERT (vt.vt == VT_BSTR);
			if (vt.vt == VT_BSTR)
				file.strName = W2A (vt.bstrVal);
		}
	}

	IXMLDOMNodePtr spItem;
	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"verification")
		{
			ReadVerificationNode (spItem, &file);			
		}

		else if (bstrName == L"resources")
		{
			ReadResourcesNode (spItem, &file);
		}

		else if (bstrName == L"os")
		{
			CComBSTR bstrText;
			spItem->get_text (&bstrText);
			file.strOS = W2A (bstrText);
		}

		spItem = NULL;
	}

	if (file.vMirrors.size () == 0)
		return FALSE;

	m_vFiles.add (file);

	return TRUE;
}