nedcomp hosting homepage

Producten en Diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

Microsoft XML Core Services (MSXML) 4.0 - DOM Reference

IXMLDOMComment

Represents the content of an XML comment.

[Script]

Example

The following script example creates a new IXMLDOMComment (comment) and appends it as the last child node of DOMDocument.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var root;
var comment;
xmlDoc.async = false;
xmlDoc.load("books.xml");
root = xmlDoc.documentElement;
comment = xmlDoc.createComment("Hello World!");
root.appendChild(comment);
alert(root.xml);
[Visual Basic]

Example

The following Microsoft® Visual Basic® example creates a new IXMLDOMComment (comment) and appends it as the last child node of DOMDocument.

Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim comment As IXMLDOMComment
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set comment = xmlDoc.createComment("Hello World!")
root.appendChild comment
MsgBox (root.xml)
[C/C++]

The following sample creates and appends a new XMLDOMComment node to the root document element.

#import "msxml4.dll"
using namespace MSXML2;

inline void TESTHR( HRESULT _hr ) 
   { if FAILED(_hr) throw(_hr); }

void XMLDOMCommentSample()
{
   try {
      IXMLDOMDocumentPtr docPtr;
      IXMLDOMNodePtr DOMNodePtr;

      //init
      TESTHR(CoInitialize(NULL)); 
      TESTHR(docPtr.CreateInstance("Msxml2.DOMDocument.4.0"));
      
      // load a document
      _variant_t varXml("C:\\book.xml");
      _variant_t varOut((bool)TRUE);
      varOut = docPtr->load(varXml);
      if ((bool)varOut == FALSE)
         throw(0);
      MessageBox(NULL, _bstr_t(docPtr->xml), _T("Original Document"), MB_OK);

      DOMNodePtr = docPtr->createComment("This is a comment node");
      docPtr->documentElement->appendChild(DOMNodePtr);

      MessageBox(NULL, _bstr_t(docPtr->xml), _T("New Document"), MB_OK);

   } catch(...)
   {
      MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
   }
   CoUninitialize();
}

Remarks

The content refers to all characters between the start <!-- and end --> tags.

IXMLDOMComment has no unique members and exposes the same members IXMLDOMCharacterData.

Requirements

Implementation: msxml4.dll, msxml2.lib

[C/C++]

Header and IDL files: msxml2.h, msxml2.idl

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

IXMLDOMCharacterData | IXMLDOMComment Members | IXMLDOMElement


Download de SDK