Buscador en XML

04/03/2004 - 20:11 por Alejandro Esteve | Informe spam
quería preguntaros si es posible realizar un sencillo buscador para la web y
que busque en ficheros XML sin usar ninguna otra tecnología

Alejandro Esteve
http://www.BibliotecaInformatica.Net
ftp://ftp.BibliotecaInformatica.Net

Preguntas similare

Leer las respuestas

#1 mlorente
04/03/2004 - 21:32 | Informe spam
Esta función realiza mas o menos eso. La busqueda la realiza leyendo el
fichero como si fuera texto. pero cambiarlo no cuesta nada.
Supongo que no te costará adaptarlo a tus necesidades, si es esto lo que
buscas.

sub TratarCarpeta(Carpeta)
Dim fso, CarpetaRoot, Carpetas, Ficheros, Fichero, ts, s, xmlDoc
Dim strSeccion, lngIni, lngFin, lngBuscar, strPalabra, strFichero

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fso = CreateObject("Scripting.FileSystemObject")
Set CarpetaRoot = fso.GetFolder(Carpeta)
Set Carpetas = CarpetaRoot.SubFolders
set Ficheros=CarpetaRoot.Files
strPalabra=Request.Form("Palabra")

if instr(1, UCASE(Fichero.Name), ".XML")=0 and instr(1,
UCASE(Fichero.Name), ".ZIP")=0 THEN
on error resume next
' Esto lo puedes sustituir
' Set f = fso.OpenTextFile(Fichero.Path , ForReading, false)
' s=f.ReadAll()
'
' esto
Set xmlDoc = CreateObject("Msxml2.FreeThreadedDOMDocument")
xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP", ".xml")
if xmlDoc.parseError=0 then
if instr(1,ucase(xmlDoc.xml),ucase(strPalabra))>0 then
' if instr(1,ucase(s),ucase(strPalabra))>0 then
Set xmlDoc CreateObject("Msxml2.FreeThreadedDOMDocument")
xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP", ".xml")
if xmlDoc.parseError=0 then
mlngCount=mlngCoun+1 response.Write "" &
xmlDoc.SelectSingleNode(".//Title").Text & ""
response.Write "" &
xmlDoc.SelectSingleNode(".//Date").Text & " - " &
xmlDoc.SelectSingleNode(".//Author").Text & ""
strSeccion=replace(ucase(replace(Fichero.Path,
Fichero.Name, "")),UCASE(Application("PathRoot")& "\SECCIONES\"),"")
strSeccion=replace(strSeccion,"\","/")
response.Write "" & left(xmlDoc.SelectSingleNode(".//Summary").Text,150) &
"..."
end if
set xmlDoc=nothing
end if
f.close
end if
end select

For Each Carpeta in Carpetas
TratarCarpeta(Carpeta.Path)
Next
end sub


Un Saludo,

Visita http://www.programemos.com




"Alejandro Esteve" wrote in message
news:u%
quería preguntaros si es posible realizar un sencillo buscador para la web


y
que busque en ficheros XML sin usar ninguna otra tecnología

Alejandro Esteve
http://www.BibliotecaInformatica.Net
ftp://ftp.BibliotecaInformatica.Net


Respuesta Responder a este mensaje
#2 Alejandro Esteve
05/03/2004 - 09:30 | Informe spam
ya, pero este código es para .Net?
yo me refería a realizarlo con XML/XSL/XForms que veo tienen implementadas
el uso de variables y diversas funciones como if, etc o bien con algún
javascript

tengo un bosquejo de lo que he realizado hasta ahora en
http://217.126.217.218/index.xml (sólo funciona el link a DFS)

gracias de todas formas
Alejandro Esteve
http://www.BibliotecaInformatica.Net
ftp://ftp.BibliotecaInformatica.Net

"mlorente" wrote in message
news:vnM1c.3782645$
Esta función realiza mas o menos eso. La busqueda la realiza leyendo el
fichero como si fuera texto. pero cambiarlo no cuesta nada.
Supongo que no te costará adaptarlo a tus necesidades, si es esto lo que
buscas.

sub TratarCarpeta(Carpeta)
Dim fso, CarpetaRoot, Carpetas, Ficheros, Fichero, ts, s, xmlDoc
Dim strSeccion, lngIni, lngFin, lngBuscar, strPalabra, strFichero

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fso = CreateObject("Scripting.FileSystemObject")
Set CarpetaRoot = fso.GetFolder(Carpeta)
Set Carpetas = CarpetaRoot.SubFolders
set Ficheros=CarpetaRoot.Files
strPalabra=Request.Form("Palabra")

if instr(1, UCASE(Fichero.Name), ".XML")=0 and instr(1,
UCASE(Fichero.Name), ".ZIP")=0 THEN
on error resume next
' Esto lo puedes sustituir
' Set f = fso.OpenTextFile(Fichero.Path , ForReading,


false)
' s=f.ReadAll()
'
' esto
Set xmlDoc CreateObject("Msxml2.FreeThreadedDOMDocument")
xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP", ".xml")
if xmlDoc.parseError=0 then
if instr(1,ucase(xmlDoc.xml),ucase(strPalabra))>0 then
' if instr(1,ucase(s),ucase(strPalabra))>0 then
Set xmlDoc > CreateObject("Msxml2.FreeThreadedDOMDocument")
xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP",


".xml")
if xmlDoc.parseError=0 then
mlngCount=mlngCoun+1 response.Write "" &
xmlDoc.SelectSingleNode(".//Title").Text & ""
response.Write "" &
xmlDoc.SelectSingleNode(".//Date").Text & " - " &
xmlDoc.SelectSingleNode(".//Author").Text & ""
strSeccion=replace(ucase(replace(Fichero.Path,
Fichero.Name, "")),UCASE(Application("PathRoot")& "\SECCIONES\"),"")
strSeccion=replace(strSeccion,"\","/")
response.Write "" & left(xmlDoc.SelectSingleNode(".//Summary").Text,150) &
"..."
end if
set xmlDoc=nothing
end if
f.close
end if
end select

For Each Carpeta in Carpetas
TratarCarpeta(Carpeta.Path)
Next
end sub


Un Saludo,

Visita http://www.programemos.com




"Alejandro Esteve" wrote in message
news:u%
> quería preguntaros si es posible realizar un sencillo buscador para la


web
y
> que busque en ficheros XML sin usar ninguna otra tecnología
>
> Alejandro Esteve
> http://www.BibliotecaInformatica.Net
> ftp://ftp.BibliotecaInformatica.Net
>
>


Respuesta Responder a este mensaje
#3 mlorente
06/03/2004 - 22:26 | Informe spam
El código es vbscript para asp. No es para asp.Net

"Alejandro Esteve" wrote in message
news:
ya, pero este código es para .Net?
yo me refería a realizarlo con XML/XSL/XForms que veo tienen implementadas
el uso de variables y diversas funciones como if, etc o bien con algún
javascript

tengo un bosquejo de lo que he realizado hasta ahora en
http://217.126.217.218/index.xml (sólo funciona el link a DFS)

gracias de todas formas
Alejandro Esteve
http://www.BibliotecaInformatica.Net
ftp://ftp.BibliotecaInformatica.Net

"mlorente" wrote in message
news:vnM1c.3782645$
> Esta función realiza mas o menos eso. La busqueda la realiza leyendo el
> fichero como si fuera texto. pero cambiarlo no cuesta nada.
> Supongo que no te costará adaptarlo a tus necesidades, si es esto lo que
> buscas.
>
> sub TratarCarpeta(Carpeta)
> Dim fso, CarpetaRoot, Carpetas, Ficheros, Fichero, ts, s, xmlDoc
> Dim strSeccion, lngIni, lngFin, lngBuscar, strPalabra, strFichero
>
> Const ForReading = 1, ForWriting = 2, ForAppending = 8
> Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set CarpetaRoot = fso.GetFolder(Carpeta)
> Set Carpetas = CarpetaRoot.SubFolders
> set Ficheros=CarpetaRoot.Files
> strPalabra=Request.Form("Palabra")
>
> if instr(1, UCASE(Fichero.Name), ".XML")=0 and instr(1,
> UCASE(Fichero.Name), ".ZIP")=0 THEN
> on error resume next
> ' Esto lo puedes sustituir
> ' Set f = fso.OpenTextFile(Fichero.Path , ForReading,
false)
> ' s=f.ReadAll()
> '
> ' esto
> Set xmlDoc > CreateObject("Msxml2.FreeThreadedDOMDocument")
> xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP",


".xml")
> if xmlDoc.parseError=0 then
> if instr(1,ucase(xmlDoc.xml),ucase(strPalabra))>0


then
> ' if instr(1,ucase(s),ucase(strPalabra))>0 then
> Set xmlDoc > > CreateObject("Msxml2.FreeThreadedDOMDocument")
> xmlDoc.load Replace(Ucase(Fichero.Path), ".ASP",
".xml")
> if xmlDoc.parseError=0 then
> mlngCount=mlngCoun+1 response.Write "" &
> xmlDoc.SelectSingleNode(".//Title").Text & ""
> response.Write "" &
> xmlDoc.SelectSingleNode(".//Date").Text & " - " &
> xmlDoc.SelectSingleNode(".//Author").Text & ""
> strSeccion=replace(ucase(replace(Fichero.Path,
> Fichero.Name, "")),UCASE(Application("PathRoot")& "\SECCIONES\"),"")
> strSeccion=replace(strSeccion,"\","/")
> response.Write "" & left(xmlDoc.SelectSingleNode(".//Summary").Text,150)


&
> "..."
> end if
> set xmlDoc=nothing
> end if
> f.close
> end if
> end select
>
> For Each Carpeta in Carpetas
> TratarCarpeta(Carpeta.Path)
> Next
> end sub
>
>
> Un Saludo,
>
> Visita http://www.programemos.com
>
>
>
>
> "Alejandro Esteve" wrote in message
> news:u%
> > quería preguntaros si es posible realizar un sencillo buscador para la
web
> y
> > que busque en ficheros XML sin usar ninguna otra tecnología
> >
> > Alejandro Esteve
> > http://www.BibliotecaInformatica.Net
> > ftp://ftp.BibliotecaInformatica.Net
> >
> >
>
>


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida