Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2003, 05:15 PM
Authorized User
 
Join Date: Jun 2003
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default asp xml

hi
have this function in asp

Function ProjectSetting(value)
dim v_objXML, v_rootnode
Set v_objXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
v_objXML.Async = False
v_objXML.Load(Server.MapPath("../configuration/settings.xml"))
set v_rootnode = v_objXML.documentElement
ProjectSetting = v_rootnode.selectsinglenode("param[@name='"" & value & ""']").text
End Function

But the function results every time in an error because variable "value" has not yet any data.

Even when I try to use the funcion WITH data, still an error.

How to work around this correctly ?

Thx a lot
 
Old September 1st, 2003, 03:20 AM
Registered User
 
Join Date: Aug 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do one thing,

dim v_objXML, v_rootnode
Set v_objXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
v_objXML.Async = False
if (v_objXML.Load(Server.MapPath("../configuration/settings.xml"))) then
set v_rootnode = v_objXML.documentElement
ProjectSetting = v_rootnode.selectsinglenode("param[@name='"" & value & ""']").text
end if

This should solve Ur Problem. The error U might be getting is becoz of the XML file not loaded, and U r trying to access the nodes before the file is loaded.

Quote:
quote:Originally posted by Kabe
 hi
have this function in asp

Function ProjectSetting(value)
dim v_objXML, v_rootnode
Set v_objXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
v_objXML.Async = False
v_objXML.Load(Server.MapPath("../configuration/settings.xml"))
set v_rootnode = v_objXML.documentElement
ProjectSetting = v_rootnode.selectsinglenode("param[@name='"" & value & ""']").text
End Function

But the function results every time in an error because variable "value" has not yet any data.

Even when I try to use the funcion WITH data, still an error.

How to work around this correctly ?

Thx a lot
Thanks and regards,

Raj Babar
 
Old September 2nd, 2003, 08:50 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think your problem is in here:

ProjectSetting = v_rootnode.selectsinglenode("param[@name='"" & value & ""']").text

What that code is actually resulting in is an XPATH querry of:

    param[@name='" & value & "']

You have extra quotes. Change it too:

ProjectSetting = v_rootnode.selectsinglenode("param[@name='" & value & "']").text

Peter
 
Old September 4th, 2003, 02:53 AM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think planoie is right.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Relational SQL Data to XML - Vet SQL/ASP - New XML JimiTheJett XML 1 December 4th, 2008 06:06 PM
post xml data from ASP.NET app to ASP app polekat Classic ASP Professional 2 January 31st, 2007 08:44 AM
xml invalid top level from ASP write XML(solution) g000we XML 0 August 9th, 2006 03:56 AM
asp xml taz Classic ASP XML 1 March 30th, 2006 12:29 PM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 04:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.