Ver Mensaje Individual
  #12 (permalink)  
Antiguo 09/06/2005, 09:56
Avatar de The_Pretorian
The_Pretorian
 
Fecha de Ingreso: diciembre-2004
Ubicación: Lima - Peru
Mensajes: 267
Antigüedad: 20 años, 3 meses
Puntos: 0
Exclamación Modificar un XML desde un ASP

Buenos Dias Amigos de Foro:
Continuando en la solución a mi problema, encontre una funcion que mas o menos se ajusta a lo que me piden.
Bueno la idea es mandar un parametro a la funcion y esta la busque y modifique en el XML. Por ejemplo Busque '001' y lo reemplaze por '002'.

1ero Les mostrare el Archivo XML que estamos usando
-----
<?xml version="1.0"?>
<main>
<cod>001</cod>
<nom>Nombre</nom>
</main>
-----

A continuacion la funcion que encontre, espero me puedan brindar su apoyo una vez mas.

-----
<%@Language=VBScript Codepage="1252"%>
<%
Function updateXML(strNuevoValor)

Dim objDom, objRoot, objContact
Dim objField, strNewEMail
'Instantiate the XMLDOM Object.
set objXML = Server.CreateObject("Microsoft.XMLDOM")
'Turn off asyncronous file loading.
objXML.async = false
'Load the XML file.
objXML.load "C:\regsitro.xml"
'Set the objRoot variable equal to the root element of the XML file by
'calling the documentElement method of the objDOM (XMLDOM) object.
Set objRoot = objXML.documentElement
'Set a reference to the node (record) of the contact that we are
'editing by calling the SelectSingleNode method and passing it the
'e-mail address of the contact we are editing.
Set objContact = objRoot.SelectSingleNode("contact[field/field_value='"
& strNuevoValor & "']")
'Iterate through the form colllection of the request object updating
'the values of the XML record.
For each objItem in Request.Form
Set objField = objContact.selectSingleNode("field[@id='" & objItem & "']/field_value")
objField.text = Request.Form(objItem)
Next
'After the XML file has been edited, is must be saved.
objXML.save strXMLFile
End Function
%>
-----


de antemano Muchas Gracias

Atte

Jorge Diaz
__________________
Creo que todas las cosas suceden por algo, no es eso que los demas llaman 'Destino'. Definitivamente Dios no juega a los dados...