Creating XML from ASP.Net 1.1

liunx

Guest
So I'm brushing up on some XML techniques when I start to think about the different ways to create XML. I've been learning ASP.Net 1.1 and am getting ready to start 2.0, so I am trying to create an XML document by using server side scripting. I am loading the information from a virtual directory using IIS, and not a database. I can get the parent node to process, displaying the folder name, but I just can't seem to get the folder contents to display. Here is the code I am using. Any help would be greatly appreciated!



'get folders
if Directory.Exists(strDirectoryLocation) then
dirs = Directory.GetDirectories(strDirectoryLocation)
for i = 0 to Ubound(dirs)
dirs(i) = replace(dirs(i), strDirectoryLocation, "")
next
Array.sort(dirs)
for i=0 to Ubound(dirs)
folderElement = MP3Xml.CreateElement("folder")
folderElement.SetAttribute("foldername", _
replace(dirs(i),"\",""))
RootNode.AppendChild(folderElement)

'get files
fileInfos = Directory.GetFiles(strDirectoryLocation _
& dirs(i) & "\", "*.mp3")
for j = 0 to Ubound(fileInfos)
fileInfos(j) = replace(fileInfos(j), strDirectoryLocation _
& dirs(i) & "\", "")
next
Array.sort(fileInfos)
for j = 0 to Ubound(fileInfos)
songElement = MP3xml.CreateElement("song")
songElement.SetAttribute("filename", fileInfos(j))
folderElement.AppendChild(songElement)
next
next
End If

'create XML content
dim strContents as String = MP3Xml.outerXML
response.write (strContents)
end sub
 
Back
Top