Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

feasso

Length mostrando sempre zero

Recommended Posts

Tenho este arquivo .xml

<?xml version="1.0" encoding="iso-8859-1"?>
<clientes>
	<cliente>
		<id>632</id>
		<email>mirao@uol.com.br</email>
		<nome>Adenir C. Do Nascimento</nome>
	</cliente>
	<cliente>
		<id>1140</id>
		<email>mirao@uol.com.br</email>
		<nome>Adenir C. Do Nascimento</nome>
	</cliente>
	<cliente>
		<id>1648</id>
		<email>mirao@uol.com.br</email>
		<nome>Adenir C. Do Nascimento</nome>
	</cliente>

Mas quando verificar o seu Length ele sempre mostra 0 (zero).

 

Para ver o Length estou fazendo assim:

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
	objXML.async = False
	objXML.load (arquivo)
	Set objLst = objXML.getElementsByTagName("cliente")
response.Write(objXML.getElementsByTagName("cliente").Length)

O que está errado ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

no XML aparentemente não tem nada errado.

você quer que eu mova para ASP ?

 

você fechou o </clientes> ? ne?!

Compartilhar este post


Link para o post
Compartilhar em outros sites

E funcionou após isso ? :lol:

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consigo ver o Length, mas não consigo ver o que tem dentro de cada tag.

objLst.item(i).childNodes(0).Text

Não está trazendo nada, o que pode estar errado ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tópico Movido:

Webstandards: CSS / XML / XHTML / HTML http://forum.imasters.com.br/public/style_emoticons/default/seta.gif ASP

Compartilhar este post


Link para o post
Compartilhar em outros sites

Set objFSO = CreateObject("Scripting.FileSystemObject")
		
	if objFSO.FileExists(arquivo) = true then
	
		conta = 0
		Set objXML = Server.CreateObject("Microsoft.XMLDOM")
		objXML.async = False
		objXML.load (arquivo)
		Set objLst = objXML.getElementsByTagName("cliente")

		if objLst.Length > 0 then
									   if objLst.Length < 5 then
			vaiate = objLst.Length - 1 
			  else
			vaiate = 4
			  end if
				   
									id	   = objLst.item(i).childNodes(0).Text&"")
			nome = objLst.item(i).childNodes(1).Text&"")
			email =objLst.item(i).childNodes(2).Text&"")

Mas quando dou um response.write estão todos em branco.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tem o for e não funcionou

Set objFSO = CreateObject("Scripting.FileSystemObject")
		
	if objFSO.FileExists(arquivo) = true then
	
		conta = 0
		Set objXML = Server.CreateObject("Microsoft.XMLDOM")
		objXML.async = False
		objXML.load (arquivo)
		Set objLst = objXML.getElementsByTagName("cliente")

		if objLst.Length > 0 then
									   if objLst.Length < 5 then
			vaiate = objLst.Length - 1 
			  else
			vaiate = 4
			  end if
			
		For i = 0 To vaiate
	   
			id	   = objLst.item(i).childNodes(0).Text&"")
			nome = objLst.item(i).childNodes(1).Text&"")
			email =objLst.item(i).childNodes(2).Text&"")

Compartilhar este post


Link para o post
Compartilhar em outros sites

if objFSO.FileExists(arquivo) = true then
			
	conta = 0
	Set objXML = Server.CreateObject("Microsoft.XMLDOM")
	objXML.async = False
	objXML.load (arquivo)
	Set objLst = objXML.getElementsByTagName("cliente")
	
	if objLst.Length > 0 then
						
		if objLst.Length < 5 then
			vaiate = objLst.Length - 1 
		else
			vaiate = 4
		end if
			
		assunto = Session("Assunto")
		news = Session("NEWS")							
	
	
		call abreRS("SELECT * FROM NEWSLETTER WHERE id_newsletter = "&news&";",rs)

		if not rs.eof then
			template = "<body>" & rs("hmtl_NEWSLETTER") & "<img src="""&url_site&"/redireciona.asp?idcli=#id#&news="&rs("id_newsletter")&""" border=""0"" alt="""" width=""0"" height=""0"" /></body>"
		
			rs("total") = totalnews
			rs.Update
		end if
	
		call fechaRS(rs)
					
		template = replace(template, "/arquivoseditor_west1/", url_site_editor & "/arquivoseditor_west1/")
				
		For i = 0 To vaiate

			template2 = replace(template,"#id#",objLst.item(i).childNodes(0).Text&"")
			template2 = replace(template2,"#email#",objLst.item(i).childNodes(1).Text&"")
			template2 = replace(template2,"#nome#",objLst.item(i).childNodes(2).Text&"")
	
			Call EnviaEmail(objLst.item(i).childNodes(2).Text&"", objLst.item(i).childNodes(1).Text, "West 1", email_contato, assunto, template)

			ultimo = objLst.item(i).childNodes(0).Text
										
			session("ultimo") = session("ultimo") + 1
						
			set nodeStory = objXML.selectSingleNode("clientes/cliente[id[.=" & chr(34) & ultimo & chr(34) & "]]")	
	
			if not nodeStory is nothing then
				' Remover
				nodeStory.parentNode.removeChild(nodeStory)
			end if
	
			set nodeStory = nothing

			conta = conta + 1
						
		Next
	
		objXML.save(arquivo)

	end if
	
	set objLst = nothing
	Set objXML = nothing

end if

set objFSO = nothing

Como coloco o for antes do if ??? Pois o for que tenho está esperando valorese do if que está acima dele.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.