473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

xml dom parsing error - selectSingleNode gives 'undefined'

Hi all!

I have written a function to fetch lebels from xml file for
cross-language interoperability. Please refer function code below.

I am invoking itfrom my asp page saying
<%=getValueForLabelNode(strLanguage,"English").toS tring()%>

It gives me an error 'Microsoft JScript runtime (0x800A138F)
'undefined' is null or not an object'

-----function code---
function getValueForLabelNode(lang, nodename)
{
try
{
// Name: getValueForLabelNode
// Input: Language code, Node name
// Output: Label Text
// Description: Fetches the Label Message for the language code
specified and the Label Name passed
// Author: IGSI - 2004

var LabelDoc= Server.CreateObject("MSXML2.DOMDocument");
var sPattern
var objLabels
var docurl
docurl = "../data/DebitMgrLabels.xml"

LabelDoc.async = false //asynchronous download not
permitted
LabelDoc.validateOnParse = true //Validates during parsing
LabelDoc.load (Server.MapPath(docurl)) //Loads the xml
resource at the passed docurl

// No parsing error
if (LabelDoc.parseError.errorCode == 0) {
//pattern to match the langauge node and corresponding Lable node
sPattern = "//language[@name='" + lang + "']//label[@name='" +
nodename + "']"

//ToDo. the below line returns undefined. Pls correct it.
objLabels = LabelDoc.selectSingleNode(sPattern);

//returning the text for the nodename passed
return objLabels.Text
}
}
catch(e)
{
return e.description;
}
}
Jul 23 '05 #1
2 7744


Rashida wrote:
I have written a function to fetch lebels from xml file for
cross-language interoperability. Please refer function code below.

I am invoking itfrom my asp page saying
<%=getValueForLabelNode(strLanguage,"English").toS tring()%>

It gives me an error 'Microsoft JScript runtime (0x800A138F)
'undefined' is null or not an object'

-----function code---
function getValueForLabelNode(lang, nodename)
{
try
{
// Name: getValueForLabelNode
// Input: Language code, Node name
// Output: Label Text
// Description: Fetches the Label Message for the language code
specified and the Label Name passed
// Author: IGSI - 2004

var LabelDoc= Server.CreateObject("MSXML2.DOMDocument");
var sPattern
var objLabels
var docurl
docurl = "../data/DebitMgrLabels.xml"

LabelDoc.async = false //asynchronous download not
permitted
LabelDoc.validateOnParse = true //Validates during parsing
LabelDoc.load (Server.MapPath(docurl)) //Loads the xml
resource at the passed docurl

// No parsing error
if (LabelDoc.parseError.errorCode == 0) {
Try to set
LabelDoc.setProperty("SelectionLanguage", "XPath");
here before you call selectSingleNode.
//pattern to match the langauge node and corresponding Lable node
sPattern = "//language[@name='" + lang + "']//label[@name='" +
nodename + "']"

//ToDo. the below line returns undefined. Pls correct it.
objLabels = LabelDoc.selectSingleNode(sPattern);


You need to show us your XML input and the values of lang and nodename
so that we can check whether your XPath expression passed to
selectSingleNode should find a matching node or not.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41***********************@newsread4.arcor-online.net>...
Rashida wrote:
I have written a function to fetch lebels from xml file for
cross-language interoperability. Please refer function code below.

I am invoking itfrom my asp page saying
<%=getValueForLabelNode(strLanguage,"English").toS tring()%>

It gives me an error 'Microsoft JScript runtime (0x800A138F)
'undefined' is null or not an object'

-----function code---
function getValueForLabelNode(lang, nodename)
{
try
{
// Name: getValueForLabelNode
// Input: Language code, Node name
// Output: Label Text
// Description: Fetches the Label Message for the language code
specified and the Label Name passed
// Author: IGSI - 2004

var LabelDoc= Server.CreateObject("MSXML2.DOMDocument");
var sPattern
var objLabels
var docurl
docurl = "../data/DebitMgrLabels.xml"

LabelDoc.async = false //asynchronous download not
permitted
LabelDoc.validateOnParse = true //Validates during parsing
LabelDoc.load (Server.MapPath(docurl)) //Loads the xml
resource at the passed docurl

// No parsing error
if (LabelDoc.parseError.errorCode == 0) {


Try to set
LabelDoc.setProperty("SelectionLanguage", "XPath");
here before you call selectSingleNode.
//pattern to match the langauge node and corresponding Lable node
sPattern = "//language[@name='" + lang + "']//label[@name='" +
nodename + "']"

//ToDo. the below line returns undefined. Pls correct it.
objLabels = LabelDoc.selectSingleNode(sPattern);


You need to show us your XML input and the values of lang and nodename
so that we can check whether your XPath expression passed to
selectSingleNode should find a matching node or not.

Thanks you! got it resolved.
Jul 23 '05 #3

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
0
by: milesd | last post by:
Hi, Rather new to MSXML4. I am parsing an XML data-stream over HTTP, and would like to know why I cannot parse XML nodes with multiple parameters. The XML and Code are below, BUT I would like...
9
by: Omkar Singh | last post by:
I try to parse a XML document containg some references using XmlDocument Class' method GetElementbyTagName. It just give the content between starting tagName and ending tagName but not all...
4
by: Erik Moore | last post by:
I am both producing and parsing an xml document that needs to be validated against a schema. I wanted some consumers of the document to have the option of not performing a validation, so I left the...
8
by: Dinçer | last post by:
I need to parse an XML file and print the contents of it on an aspx page. My XML file structure is like this: <QueryResult> <messageNo>1</messageNo> <messageText /> <HERE>...
1
by: Stephen | last post by:
Hi, I am talking to a webservice for stock quote. I invoke the "getQuote" method of the webservice by supplying the Company Symbol and it return me the result. I want to parse the specific...
9
by: B | last post by:
I have an XML string <?xml version="1.0" encoding="UTF-8"?> <SSOUser><Status>FAIL</Status><Message>Unable to find session id of 1137018716939</Message></SSOUser> That I am trying to...
0
by: XML newbie: Urgent pls help! | last post by:
When I try to parse: I get the following error message: Unable to cast COM object of type 'Microsoft.SqlServer.MSXML6.DOMDocumentClass' to interface type 'MSXML2.ServerXMLHTTP40'. This operation...
0
by: XML newbie: Urgent pls help! | last post by:
I am using Vb.net. I am new to XML.I appreciate your help in advance. Please reply soon. When I try to parse: I get the following error message: Unable to cast COM object of type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.