473,796 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Reading


I'm having some problem with reading an .xml file:

<?xml version="1.0" encoding="utf-8"?>
<UserInfoListRe sult xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/">
<Result>true</Result>
<ResultCode>0 </ResultCode>
<Message />
<Users>
<UserInfo>
<UserName>tes t</UserName>
<Password>tes t</Password>
<FirstName>test </FirstName>
<LastName />
<IsSystemAdmin> false</IsSystemAdmin>
<IsDomainAdmin> true</IsDomainAdmin>
</UserInfo>
<UserInfo>
<UserName>test2 </UserName>
<Password>test2 </Password>
<FirstName>test 2</FirstName>
<LastName />
<IsSystemAdmin> false</IsSystemAdmin>
<IsDomainAdmin> false</IsDomainAdmin>
</UserInfo>
</Users>
</UserInfoListRes ult>

How could I retrieve in a loop username,passwo rd,firstname?

Thanks very much

--
Creascripts
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 11 '06 #1
2 1301
Creascripts wrote:
I'm having some problem with reading an .xml file:

<?xml version="1.0" encoding="utf-8"?>
<UserInfoListRe sult xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/">
<Result>true</Result>
<ResultCode>0 </ResultCode>
<Message />
<Users>
<UserInfo>
<UserName>tes t</UserName>
<Password>tes t</Password>
<FirstName>test </FirstName>
<LastName />
<IsSystemAdmin> false</IsSystemAdmin>
<IsDomainAdmin> true</IsDomainAdmin>
</UserInfo>
<UserInfo>
<UserName>test2 </UserName>
<Password>test2 </Password>
<FirstName>test 2</FirstName>
<LastName />
<IsSystemAdmin> false</IsSystemAdmin>
<IsDomainAdmin> false</IsDomainAdmin>
</UserInfo>
</Users>
</UserInfoListRes ult>

How could I retrieve in a loop username,passwo rd,firstname?

Thanks very much

<%
option explicit
dim xdoc, uname, pwd, fname, users, details
set xdoc=createobje ct("msxml2.domd ocument")
xdoc.load server.mappath( "xml/yourfile.xml")
If xdoc.parseError .errorCode = 0 Then
Response.Write "<table><tr><th >UserName</th><th>" & _
"Password</th><th>First Name</th><tr>"
set users = nothing
set users = xdoc.selectnode s("/UserInfoListRes ult/Users/UserInfo")
if not users is nothing then
for each details in users
Response.write "<tr><td>"
set uname=nothing
set uname= details.selects inglenode("User Name")
if not uname is nothing then
Response.Write server.HTMLEnco de(uname.text)
else
Response.Write "&nbsp;"
end if
Response.Write "</td><td>"
set pwd=nothing
set pwd= details.selects inglenode("Pass word")
if not pwd is nothing then
Response.Write server.HTMLEnco de(pwd.text)
else
Response.Write "&nbsp;"
end if
Response.Write "</td><td>"
set fname=nothing
set fname= details.selects inglenode("Firs tName")
if not fname is nothing then
Response.Write server.HTMLEnco de(fname.text)
else
Response.Write "&nbsp;"
end if
Response.Write "</td></tr>"
next
Response.Write "</table>"
else
Response.Write "Either the xml contained no user info " & _
"or the xpath query was badly stated"
end if
Else
' error parsing data
With xdoc.parseError strError = "Error Parsing XML Data:" & "
" & "
" & _ "Error Code: " & .errorCode & "
" & _ "Error Description: " & .reason & "
" & _ "Error Line: " & .line & "
" & _ "Error Line Position: " & .linepos & "
" & _ "Error File Position: " & .filepos & "
" & _ "Error Source: " & .srcText End With
Response.Write "<Error>" & strError & "</Error>"
End If
%>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Nov 11 '06 #2
Bob Barrows [MVP] wrote:
>
<%
option explicit
dim xdoc, uname, pwd, fname, users, details
set xdoc=createobje ct("msxml2.domd ocument")
xdoc.load server.mappath( "xml/yourfile.xml")
You do, of course, need to change this to your path and file name.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Nov 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3594
by: Andy | last post by:
Hi, In the code below (not pretty I know but it's an early version :-P) I'm having problems reading the data object back in. If I move the reading code to immediately after the section where it is written ( commented out in code) then it reads in OK. However, when I move the code to the right place ( as shown here) it throws an IO exception. Both the Filter class and it's constituent class implement Serializable and it would seem the...
6
2413
by: Raymond Hettinger | last post by:
Found in a pamphlet at a pre-school: --------------------------------------- Reading improves vocabulary Reading raises cultural literacy through shared knowledge Reading develops writing skills Reading opens the mind to new ways of understanding Reading is fun Accordingly, I suggest the following works of literature:
4
3070
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
24
2765
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
19
10382
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much text is available until I have read it... which seems to imply that multiple reads of the input stream will be inevitable. Now I can correctly find the number of characters available by: |
4
9844
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile = tmpfile(); /* write into tmpFile */ ...
6
3796
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am trying to read a flatfile. In COBOL, my simple file layout and READ statement would look like below. Question: what is the standard, simple coding convention for reading in a flatfile - one record at a time?? SCANF does not work because of...
3
9515
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At the end of this message is the inflate method this is where I get stuck I know that I need a byte array but because I am decompressing a string I have no idea of how big the byte array will need to be in the end (the inflate and deflate methods...
9
5523
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex http://www.developersdex.com ***
4
3267
by: Gaijinco | last post by:
I had a file named nap.in which looks like this: 4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00 Lunch, just lunch.
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.