
23/09/2008, 09:46
|
 | | | Fecha de Ingreso: agosto-2006 Ubicación: Santiago
Mensajes: 120
Antigüedad: 18 años, 7 meses Puntos: 0 | |
Respuesta: Servicios Web serializacion atributos Hola
Esta es una clase que fabrique en un minuto, serializa pero en forma manual
aqui te dejo el codigo
Imports Microsoft.VisualBasic
Imports System.Xml
Public Class GeneraXml
Public nameatri As String
Public valueatri As String
Public Sub xmldeclaracion(ByRef docxml As XmlDocument, _
ByVal version As String, _
ByVal Encoding As String)
Dim xdec As XmlDeclaration = docxml.CreateXmlDeclaration(version, Encoding, "")
docxml.AppendChild(xdec)
End Sub
Public Sub xmlnodocero(ByRef docxml As XmlDocument, _
ByVal nameelemento As String, _
ByVal valueelemento As String)
Dim xelecero As XmlElement = docxml.CreateElement(nameelemento)
If nameatri <> Nothing Then
xelecero.SetAttribute(nameatri, valueatri)
End If
If valueelemento <> Nothing Then
xelecero.InnerText = valueelemento
End If
docxml.AppendChild(xelecero)
End Sub
Public Sub xmlnodopadre(ByRef docxml As XmlDocument, _
ByVal nameelemento As String, _
ByVal valueelemento As String, _
ByRef nodopadre As XmlElement _
)
nodopadre = docxml.CreateElement(nameelemento)
If nameatri <> Nothing Then
nodopadre.SetAttribute(nameatri, valueatri)
End If
If valueelemento <> Nothing Then
nodopadre.InnerText = valueelemento
End If
docxml.DocumentElement.AppendChild(nodopadre)
End Sub
Public Sub xmlnodohijo(ByRef docxml As XmlDocument, _
ByVal nameelemento As String, _
ByVal valueelemento As String, _
ByVal nodopadre As XmlElement, _
ByRef nodohijo As XmlElement _
)
nodohijo = docxml.CreateElement(nameelemento)
If nameatri <> Nothing Then
nodohijo.SetAttribute(nameatri, valueatri)
End If
If valueelemento <> Nothing Then
nodohijo.InnerText = valueelemento
End If
nodopadre.AppendChild(nodohijo)
End Sub
End Class
'**********************
se llama
Public Sub xml_(ByRef xdoc As XmlDocument, _
ByRef nivel1 As XmlElement)
Dim xmlg As New GeneraXml
Dim nivel2 As XmlElement = Nothing
xmlg.xmldeclaracion(xdoc, "1.0", Encoding.UTF8.HeaderName)
'--------------
'/****Nodo cero
xmlg.xmlnodocero(xdoc, "NODO_CERO", Nothing)
'/****fin Nodo cero
'/************************-Cabezera---------
'crea nodo padre
xmlg.xmlnodopadre(xdoc, "PADRE", Nothing, nivel1)
'crea nodo HIJOS
xmlg.xmlnodohijo(xdoc, "HIJO1", "MI DATO1", nivel1, nivel2)
xmlg.xmlnodohijo(xdoc, "HIJO2", "MI DATO2", nivel1, nivel2)
End Sub
__________________ Es facil apretar tornillos, pero lo complejo es saber que tornillo apretar |