Tema: ordenar xml
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/01/2014, 03:01
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
ordenar xml

Hola,
Os comento lo que necesito a ver si me podéis ayudar.
Tengo un función en la que guardo unas datos en unas variables y esta después de llamar a unas funciones que hacen unas comprobaciones, crea el primer tag de un xml y llama varias veces a una función que lo que hace es cargar los datos en el xml y al salir del bucle que hay en la primera función llama de nuevo a esa función que genera el xml para cargar los datos que faltan ya que los datos que faltan son cosas que tengo que calcular de lo anterior.

Os dejo la función esta para que entendáis mejor (marco en negrita la función que se encarga de generar el xml):

Código vb:
Ver original
  1. Private Sub sExtraerDatosXML(ByVal oCentro)
  2. Dim oHijo, oNieto, oBizNieto, oRaiz   As MSXML2.IXMLDOMNode
  3. Dim oXMLDocFSGS As MSXML2.DOMDocument60
  4.  
  5. On Error GoTo error:
  6.  
  7.     If oCentro.Attributes(0).baseName = "code" Then
  8.         strInCODE = oCentro.Attributes(0).Text
  9.         strInCODE = Left(strInCODE, 15) 'ACORTAR A 100
  10.    End If
  11.  
  12.     iImporte = 0
  13.  
  14.     For Each oHijo In oCentro.childNodes
  15.         Select Case oHijo.nodeName
  16.             Case "FirstPeriod"
  17.                 strInFECINIYEAR = IIf(IsNull(oHijo.Attributes(0).Text), "", oHijo.Attributes(0).Text)
  18.                 strInFECINIMTH = IIf(IsNull(oHijo.Attributes(1).Text), "", oHijo.Attributes(1).Text)
  19.             Case "LastPeriod"
  20.                 strInFECFINYEAR = IIf(IsNull(oHijo.Attributes(0).Text), "", oHijo.Attributes(0).Text)
  21.                 strInFECFINMTH = IIf(IsNull(oHijo.Attributes(1).Text), "", oHijo.Attributes(1).Text)
  22.             Case "AssetCategories"
  23.                 Call sValidarDatosCode
  24.                 FechaINI = DateSerial(strInFECINIYEAR, strInFECINIMTH + 0, 1)
  25.                 FechaFIN = DateSerial(strInFECFINYEAR, strInFECFINMTH + 1, 0)
  26.                 Call calcularUON1(strInCODE)
  27.                 'GENERAR PRIMERA PARTE DEL XML
  28.                Set oXMLDocFSGS = New MSXML2.DOMDocument60            
  29.                 Set oRaiz = oXMLDocFSGS.createNode(NODE_ELEMENT, "PARTIDAS", "")
  30.                 oXMLDocFSGS.appendChild oRaiz
  31.                
  32.                 For Each oNieto In oHijo.childNodes
  33.                     Select Case oNieto.nodeName
  34.                         Case "AssetCategory"
  35.                             strInCATEGORYCODE = IIf(IsNull(oNieto.Attributes(0).Text), "", oNieto.Attributes(0).Text)
  36.                             strInCATEGORYDESCRIPT = IIf(IsNull(oNieto.Attributes(1).Text), "", oNieto.Attributes(1).Text)
  37.                             strInCATEGORYCASH = IIf(IsNull(oNieto.Attributes(2).Text), "", oNieto.Attributes(2).Text)
  38.                             For Each oBizNieto In oNieto.childNodes
  39.                                 Select Case oBizNieto.nodeName
  40.                                     Case "AccountingAmount"
  41.                                         strInAMOUNTCURRENCY = IIf(IsNull(oBizNieto.Attributes(0).Text), "", oBizNieto.Attributes(0).Text)
  42.                                         strInIMPORTE = IIf(IsNull(oBizNieto.Text), "", oBizNieto.Text)
  43.                                 End Select
  44.                             Next
  45.                     End Select
  46.                     'guarda en importe para luego mandarlo en el importe general
  47.                    iImporte = CDbl(Replace(strInIMPORTE, ".", ",")) + iImporte                    
  48.                     Call sValidarDatosCategory(CDbl(Replace(strInIMPORTE, ".", ",")))
  49.                     [B]TratarAsset oXMLDocFSGS, oRaiz, strACCIONNivel2, strInCATEGORYDESCRIPT, strInCATEGORYCODE, CDbl(Replace(strInIMPORTE, ".", ",")), strInCODE[/B]
  50.                 Next
  51.         End Select
  52.     Next
  53.     'genera los datos del xml que faltan metiendo el importe general
  54.    [B]TratarAsset oXMLDocFSGS, oRaiz, strACCIONNivel1, "code", strInCODE, iImporte, strInCODE[/B]
  55.     Set oHijo = Nothing
  56.     Exit Sub
  57. error:
  58. End Sub
__________________
Gracias por todo;

Un saludo