OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Java NPE at node.getAttribute( )

[ Lists Home | Date Index | Thread Index ]

Not sure if this will help you, but this VBScript code works fine:

	dim oDoc : set oDoc = server.createobject("MSXML.DomDocument")

	oDoc.LoadXML "<applet><transport name='jrmp'/><transport
name='codebase'/></applet>"

	Dim nsr: set nsr = oDoc.DocumentElement
	Dim nodeList : set nodeList=nsr.selectNodes("/applet/transport")

	Dim node:  set node= nodeList.item(0)
	Dim trans_val1 : trans_val1 = node.getAttribute("name")


	Dim node1 :  set node1=nodeList.item(1)
	Dim trans_val2 : trans_val2 = node1.getAttribute("name")

	response.write "<br>Name of item(1)=" & trans_val1
	response.write "<br>Name of item(2)=" & trans_val2
 
So, the xpath part of the code works as I would expect. Maybe namespaces or
some other difference would explain your problem.

-----Original Message-----
From: Nishi Prafull [mailto:nishiprafull@gmail.com] 
Sent: 24 January 2005 23:06
To: John Rivett-Carnac
Cc: xml-dev@lists.xml.org
Subject: Re: [xml-dev] Java NPE at node.getAttribute( )

Hi John:
I tried your suggestion:
 NodeList nodeList=xmlDocument.selectNodes("/applet/transport", nsr);
  XMLElement  node=(XMLElement)nodeList.item(0);
  String trans_val1 = node.getAttribute("name");

But I still get a NPE at node.getAttribute("name").

Can you suggest anything?

Thanks.

On Mon, 24 Jan 2005 22:00:06 -0000, John Rivett-Carnac
<jbrc@blueyonder.co.uk> wrote:
> 
> I think you should get the "transport" nodes in a node collection, 
> then get the name attribute of each transport node:
> 
> NodeList nodeList=xmlDocument.selectNodes("/applet/transport", nsr); 
> XMLElement  node=(XMLElement)nodeList.item(0);
> String trans_val1 = node.getAttribute("name");
> 
>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS