title image


Smiley Re: Buch Literatur für XML und DomDocument für VB
HI,



dazu brauchst du eine bessere Help als VB sie anbietet. Sauge Dir von Micorosoft die neuere Win32Platform-SDK für WinServer2003. Sind ja nur 400 MB.



Beispeil daraus: DomDocument::createElement





createElement Method Send feedback

See Also

Language Filter: All Language Filter: Multiple Language Filter: Visual Basic Language Filter: C# Language Filter: C++ Language Filter: J# Language Filter: JScript

Visual Basic (Declaration)

Visual Basic (Usage)

C#

C++

J#

JScript



Creates an element node using the specified name.



Creates an element node using the specified name.



JScript Syntax

Copy Code

var objXMLDOMElement = oXMLDOMDocument.createElement(tagName);





Parameters

tagName





A string specifying the name for the new element node. The name is case-sensitive. This name is subsequently available as the element node's nodeName property.



Return Value

An object. Returns the IXMLDOMElement object for the new element.



Example

The following script example creates an element called NEW and appends it to an IXMLDOMNode object. It then sets the text value of the element to 123.



JScript Copy Code

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");

var root;

var newElem;

xmlDoc.async = false;

xmlDoc.loadXML("");

if (xmlDoc.parseError.errorCode != 0) {

var myErr = xmlDoc.parseError;

WScript.Echo("You have error " + myErr.reason);

} else {

root = xmlDoc.documentElement;

newElem = xmlDoc.createElement("NEW");

root.childNodes.item(0).appendChild(newElem);

root.childNodes.item(0).lastChild.text = "123";

WScript.Echo(root.childNodes.item(0).xml);

}





Output

Copy Code







Visual Basic Syntax

Copy Code

Set objXMLDOMElement = oXMLDOMDocument.createElement(tagName)





Parameters

tagName





A string specifying the name for the new element node. The name is case-sensitive. This name is subsequently available as the element node's nodeName property.



Return Value

An object. Returns the IXMLDOMElement object for the new element.



Example

The following Microsoft® Visual Basic® example creates an element called NEW and appends it to an IXMLDOMNode object. It then sets the text value of the element to 123.



Visual Basic Copy Code

Dim xmlDoc As New Msxml2.DOMDocument30

Dim root As IXMLDOMElement

Dim newElem As IXMLDOMElement

xmlDoc.async = False

xmlDoc.loadXML ""

If (xmlDoc.parseError.errorCode 0) Then

Dim myErr

Set myErr = xmlDoc.parseError

MsgBox("You have error " & myErr.reason)

Else

Set root = xmlDoc.documentElement

Set newElem = xmlDoc.createElement("NEW")

root.childNodes.Item(0).appendChild newElem

root.childNodes.Item(0).lastChild.Text = "123"

MsgBox root.childNodes.Item(0).xml

End If





Output

Copy Code







C/C++ Syntax

Copy Code

HRESULT createElement(

BSTR tagName,

IXMLDOMElement **element);





Parameters

tagName[in]





The name for the new element node. It is case-sensitive. This name is subsequently available as the element node's nodeName property.



element[out,retval]





The address of the IXMLDOMElement interface for the new element.



Return Values

S_OK





The value returned if successful.



E_INVALIDARG





The value returned if the element parameter is Null.



E_FAIL





The value returned if an error occurs.



Remarks

Creating an element with this method is the same as using createNode where the type parameter value is NODE_ELEMENT and no namespace is specified.



You cannot create a namespace-qualified element using the createElement method. Regardless of whether a namespace prefix is included in the tagName parameter, the namespaceURI property for the new element node is set to an empty string, "". An element node constructed as part of an XML document load operation will never have both a prefix and an empty namespace Uniform Resource Identifier (URI). You can only create a namespace-qualified element using the createNode method of the DOMDocument object.



Although this method creates the new object in the context of this document, it does not automatically add the new object to the document tree. In other words, although the ownerDocument property of the new node points to this document object, the parentNode property is set to Null. To add the new object, you must explicitly call one of the node insert methods, insertBefore method, replaceChild method, or appendChild method.



The nodeType property has the value NODE_ELEMENT.



Versioning

Implemented in: MSXML 3.0 and later



Applies to

IXMLDOMDocument/DOMDocument



See Also

Concepts

createNode Method

namespaceURI Property (IXMLDOMNode)

ownerDocument Property

parentNode Property

nodeName Property

nodeType Property

insertBefore Method

replaceChild Method

appendChild Method

IXMLDOMElement


Programmierst Du noch frei oder wirst Du schon von Microsoft verwaltet ( .NET)?



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: