niidmore
asked on
unable to load xml files
Hello,
I have a bunch of XML files in the folder and I am trying to read all the files and write it back to some other location with slight changes in the file.
However, I am getting object error message on the selectNodes line.
Please can someone help me out in this.
Regards
Sam
I have a bunch of XML files in the folder and I am trying to read all the files and write it back to some other location with slight changes in the file.
However, I am getting object error message on the selectNodes line.
Please can someone help me out in this.
Regards
Sam
<%
Dim xmlSource, fso, file, uname
Set xmlSource = Server.CreateObject("MSXML2.DOMDocument")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set theFolder = fso.getFolder("e:\account\data\groups")
for Each f In theFolder.files
xmlSource.load "e:\account\data\groups\" & f.name
uname = xmlSource.documentElement.selectSingleNode("username").text
s = s & "<user><DateCreated/><CreatedBy/><DataAccess/><ExpiryDate/>"
s = s & "<ExcludeUser>False</ExcludeUser>"
s = s & "<Username>" & uname & "</Username>"
s = s & "<GroupName>CESUsers</GroupName>"
s = s & "<DateLastUpdated>1/31/2008 4:06:30 PM</DateLastUpdated>"
s = s & "<LastUpdatedBy>1234</LastUpdatedBy></user>"
filename = uname & ".xml"
set file = fso.CreateTextFile("e:\test\" & filename) '"
file.write s
file.close
cnt = cnt + 1
s = ""
Next
%>
My first gues is that you need the correct xml-path to the username element.
So this might work:
uname = xmlSource.selectSingleNode ("users/us er/usernam e").text 'Leave out the [documentElement]
But to know for sure i need to know the format of your xml files
So this might work:
uname = xmlSource.selectSingleNode
But to know for sure i need to know the format of your xml files
ASKER
hello norush,
thanks for your reply,
1) error
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/ces/loadcesusers.asp, line 20
line 20 is uname = xmlSource.documentElement. selectSing leNode("us ername").t ext
2) structure
<user>
<username>001</username>
<GroupName>testUser</Group Name>
<DateLastUpdated>1/31/2008 4:06:30 PM</DateLastUpdated>
<LastUpdatedBy>1234</LastU pdatedBy>
</user>
thanks for your reply,
1) error
Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/ces/loadcesusers.asp, line 20
line 20 is uname = xmlSource.documentElement.
2) structure
<user>
<username>001</username>
<GroupName>testUser</Group
<DateLastUpdated>1/31/2008
<LastUpdatedBy>1234</LastU
</user>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. What error do you get?
2. Can you show the structure of the xml files ?