fox_statton
asked on
XML Dom GetAttribute in ASP?
Hi all, Ive being trying to do something relatively simple but forwhatever reason its not working.
Ive got the following XML file and want to get the attribute "time" out of it,
<?xml version="1.0" ?>
- <note time="12:03:46">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading >
<body>Don't forget me this weekend!</body>
</note>
I was using the following code but it doesnt work...
<%
Set xmlDoc = Server.CreateObject("Micro soft.XMLDO M")
xmlDoc.async = False
'load xml file
xmlDoc.Load(Server.MapPath ("sys.xml" ))
set strX=xmlDoc.getElementsByT agName("it em")
set strY=strX.item(0).getAttri bute("id")
response.write strY
%>
Thanks!
Alicia
Ive got the following XML file and want to get the attribute "time" out of it,
<?xml version="1.0" ?>
- <note time="12:03:46">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading
<body>Don't forget me this weekend!</body>
</note>
I was using the following code but it doesnt work...
<%
Set xmlDoc = Server.CreateObject("Micro
xmlDoc.async = False
'load xml file
xmlDoc.Load(Server.MapPath
set strX=xmlDoc.getElementsByT
set strY=strX.item(0).getAttri
response.write strY
%>
Thanks!
Alicia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Try this:
Set xmlDoc = Server.CreateObject("MSXML 2.DOMDocum ent")
xmlDoc.async = False
'load xml file
If Not xmlDoc.Load(Server.MapPath ("sys.xml" )) Then
Response.write "Error parsing XML: " & xmlDoc.parseError.reason
End If
set oTimeAttr=xmlDoc.selectSin gleNode("/ note/@time ")
sTime=oTimeAttr.nodeValue
response.write sTime
>S'Plug<
Try this:
Set xmlDoc = Server.CreateObject("MSXML
xmlDoc.async = False
'load xml file
If Not xmlDoc.Load(Server.MapPath
Response.write "Error parsing XML: " & xmlDoc.parseError.reason
End If
set oTimeAttr=xmlDoc.selectSin
sTime=oTimeAttr.nodeValue
response.write sTime
>S'Plug<
ASKER
Got it working, prob was in the xml!
Ha Ha.
If I could have a pound for everytime I have done that, I would be playing golf right now, or perhaps on a beach somewhere hot.
Anyway, glad it's working.
If I could have a pound for everytime I have done that, I would be playing golf right now, or perhaps on a beach somewhere hot.
Anyway, glad it's working.
ASKER
Microsoft VBScript runtime error '800a01a8'
Object required: 'strx.Item(...)'
/sf27621/menu4/mock4/attri