Ciao a tutti!
premetto di sapere poco niente sulla lettura di xml tramite ASP e avendo imparato giuro i passi base per la lettura e "rielaborazione" dati di un file xml volevo sapere come, e se è possibile, verificare se sono presenti o meno "nodi" in una "categoria".
faccio un esempio per capire meglio
file .xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<main>
<root>
<villa>
<address>Menaggio</address>
<propertyname>Bellavista</propertyname>
<pricelow>680</pricelow>
</villa>
<villa>
<address>Como</address
</villa>
</root>
</main>
file .asp:
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
'Carica il file XML
strFile = Server.MapPath("prova.xml")
objXML.Load (strFile)
Set AllItems = objXML.selectNodes("//root")
%>
<%
For I = 0 to (AllItems.Length - 1)
Set villa = AllItems(I).selectNodes("villa")
For J = 0 to (villa.Length-1)
'Recupero i dati...
Set address = villa(J).selectNodes("address")
Set propertyname = villa(J).selectNodes("propertyname")
Set pricelow = villa(J).selectNodes("pricelow ")
if terrace(0).text<>"" then
response.Write(terrace(0).text)
end if
Set address = nothing
Set propertyname = nothing
Set pricelow = nothing
Next
Set villa = Nothing
Next
%>
naturalmente quel IF che ho inserito on va'....sapete come poter dire che se un nodo non è presente allora non stampare nulla?
grazie
Ciao!

Rispondi quotando