• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Hello, I need a help with this Server.CreateObject("MSXML2.DOMDocument.3.0")

hello guys.

In my application which I am doing support I am not familiar with this:
Could someone give some explanation about?

Server.CreateObject("MSXML2.DOMDocument.3.0")
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
 'Carga síncrona. Não passe para a próxima instrução sem carregar o xml inteiro.
objXMLDoc.async = false
'Carregue a string XML, já tomando cuidado com caracteres acentuados.
objXMLDoc.loadXML "<?xml version=""1.0"" encoding=""ISO-8859-1""?>" &_
Application("UsuariosLogados")
'Criar um novo elemento
Set objUsuario = objXMLDoc.createElement("usuario")
'Setar os atributos "id" e "nome"
objUsuario.setAttribute "sessionid", Session.SessionId
objUsuario.setAttribute "idhtlink", "1"
objUsuario.setAttribute "idspr", "1"
objUsuario.setAttribute "login", "Anônimo"
objUsuario.setAttribute "razao", "1"
objUsuario.setAttribute "tipo", "1"
objUsuario.setAttribute "limite", "1"
objUsuario.setAttribute "data", now()
objUsuario.setAttribute "url", Request.ServerVariables("url")
objUsuario.setAttribute "url2", Request.ServerVariables("REMOTE_ADDR")
objUsuario.setAttribute "mensagem", "1"

'Adicionar o novo elemento ao documento já existente
objXMLDoc.documentElement.appendChild objUsuario
'Atualizar variável de aplicação
 Application("UsuariosLogados") = objXMLDoc.documentElement.xml
'Liberar recursos alocados com o objeto
 Set objXMLDoc = Nothing
0
hidrau
Asked:
hidrau
  • 3
  • 2
2 Solutions
 
jplevyakCommented:
The code is appending a new <usuario> element to an existing set of <usuario> elements stored within the application variable as a string.

-----------------------------------------------------------------------------------
The segment below is loading an existing set of <usuario> elements stored within the Application variable as a string into an xml document
-------------------------------------------------------------------------------------
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
 'Carga síncrona. Não passe para a próxima instrução sem carregar o xml inteiro.
objXMLDoc.async = false
'Carregue a string XML, já tomando cuidado com caracteres acentuados.
objXMLDoc.loadXML "<?xml version=""1.0"" encoding=""ISO-8859-1""?>" &_
Application("UsuariosLogados")

-----------------------------------------------------------------------------------
The segment below creates a new <usuario> element and sets all the attributes for the element
-----------------------------------------------------------------------------------
'Criar um novo elemento
Set objUsuario = objXMLDoc.createElement("usuario")
'Setar os atributos "id" e "nome"
objUsuario.setAttribute "sessionid", Session.SessionId
objUsuario.setAttribute "idhtlink", "1"
objUsuario.setAttribute "idspr", "1"
objUsuario.setAttribute "login", "Anônimo"
objUsuario.setAttribute "razao", "1"
objUsuario.setAttribute "tipo", "1"
objUsuario.setAttribute "limite", "1"
objUsuario.setAttribute "data", now()
objUsuario.setAttribute "url", Request.ServerVariables("url")
objUsuario.setAttribute "url2", Request.ServerVariables("REMOTE_ADDR")
objUsuario.setAttribute "mensagem", "1"

---------------------------------------------------------------------------------
The final segment below appends this new <usuario> element within the xml document and assigns the entire xml document as text to the original Application variable.
---------------------------------------------------------------------------------
'Adicionar o novo elemento ao documento já existente
objXMLDoc.documentElement.appendChild objUsuario
'Atualizar variável de aplicação
 Application("UsuariosLogados") = objXMLDoc.documentElement.xml
'Liberar recursos alocados com o objeto
 Set objXMLDoc = Nothing
0
 
hidrauAuthor Commented:
Ok, thanks
0
 
hidrauAuthor Commented:
where can I get a good stuff to learn XML XLS?
0
 
jplevyakCommented:
O'Reilly xml.com
http://www.xml.com/

David Silverlight's XMLPitstop.com
http://www.xmlpitstop.com/

PerfectXML.com (contains whole section on Microsoft's MSXML library)
http://www.perfectxml.com/

ZVON.org - The Guide to the XML Galaxy
http://www.zvon.org/

W3Schools (Xml Tutorial)
http://www.w3schools.com/xml/default.asp
0
 
hidrauAuthor Commented:
thanks very much
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now