XML Declarations

10/08/2005 - 17:06 por Emy | Informe spam
Hola, me surgio un problema al desarrollar un xml bajo visual basic 6.
Necesito saber como crear un xml declaration con un DOM, ya que pude
desarrollar todo el archivo xml salvo dicha declaration.

Gracias.

Preguntas similare

Leer las respuestas

#1 skar
22/08/2005 - 16:40 | Informe spam
aca te mando unos pequenios ejemplos que puse hace un tiempo atras:
este comando aniadera un nuevo elemento a un documento xml

Private Sub cmdadd_Click()
Dim xmlDoc As MSXML2.DOMDocument
Dim root
Dim newElem
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set newElem = xmlDoc.createElement("PAGES")
root.childNodes.Item(1).appendChild newElem
root.childNodes.Item(1).lastChild.Text = "400"
MsgBox root.childNodes.Item(1).xml
xmlDoc.save ("test.xml")
End Sub

Private Sub cmdappend_Click()
Dim xmlDoc As MSXML2.DOMDocument
Dim root
Dim newElem
Dim refElem

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.Load ("books.xml")
'create new element
Set newElem = xmlDoc.createElement("pages")
'start from the root element
Set root = xmlDoc.documentElement
'find the first child of the root element (using collection syntax)
Set firstElem = root.childNodes.Item(1)
'find the first child of the first child (using property syntax)
Set refElem = firstElem.firstChild
'insert our new pages element
root.childNodes.Item(1).insertBefore newElem, refElem
'report the content of the first child of the root element
MsgBox firstElem.xml
xmlDoc.save ("test.xml")

End Sub

Private Sub cmdparse1_Click()
On Error GoTo ErrLog
Dim xmlDoc As MSXML2.DOMDocument
Dim mydoc As Object

Dim MyXMLText As String

Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async = False

xmlDoc.Load ("CRUISEH.xml")

If (xmlDoc.parseError <> 0) Then
MsgBox xmlDoc.parseError.reason
Else
Set mydoc = xmlDoc.documentElement
'Set mydoc = XmlDoc.documentElement.getElementsByTagName(newprice)
End If

For Each child In mydoc.childNodes
MsgBox child.Text
Next
'MsgBox mydoc.Item(0).xml

ErrLog:

If Err.Number <> 0 Then
Screen.MousePointer = vbNormal
MsgBox Err.Number & " " & Err.Description, vbInformation,
strMessageDesc
End If

End Sub

Private Sub cmdremove_Click()
Dim xmlDoc As MSXML2.DOMDocument
Dim root
Dim oldChild
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
'find the first child of the root element (using collection syntax)
Set firstElem = root.childNodes.Item(1)
Set oldChild = firstElem.firstChild
firstElem.removeChild oldChild
MsgBox firstElem.xml
xmlDoc.save ("test.xml")
End Sub

Private Sub cmdsave_Click()
Dim xmlDoc As MSXML2.DOMDocument
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.Load ("books.xml")
xmlDoc.save ("sample.xml")

End Sub

"Emy" wrote in message
news:e7%
Hola, me surgio un problema al desarrollar un xml bajo visual basic 6.
Necesito saber como crear un xml declaration con un DOM, ya que pude
desarrollar todo el archivo xml salvo dicha declaration.

Gracias.


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida