Ask a Question related to ASP.NET General, Design and Development.
-
Kathy Burke #1
xpath following-sibling - null return looks for object reference?
I'm providing the following syntax in hopes someone could tell me why I
get an object reference error on the second one. The first one works,
using an xmlDocument, the second one immediately follows and uses the
same xmlDocument. It works if the result is not Nothing. I've used
similar xpath expressions (but never with the following-sibling
reference) and the If Nothing works ok. Spent hours on this, but I need
another set of eyes and a better brain! The varStation is correct when I
check with debug. Thanks. Kathy
Dim xDoc As New XmlDocument()
xDoc.LoadXml(varWF)
'get previous station
Dim n2 As XmlElement = xDoc.SelectSingleNode("//Station[@name='" &
varStation & "']/preceding-sibling::Station[1]")
Dim prevStation As String = n2.Attributes.GetNamedItem("name").Value
'get next station name
Dim n14 As XmlElement = xDoc.SelectSingleNode("//Station[@name='" &
varStation & "']/following-sibling::Station[position()=1]")
If n14 Is Nothing Then 'ERRORS HERE - OBJECT REFERENCE
Session("NextStation") = "End of Assembly"
Else
Session("NextStation") = n14.Attributes.GetNamedItem("name").Value
End If
MY XML string (varWF):
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="WI_Workflow.xsl"?>
<WorkFlow>
<Assembly number="865-7446-03-BA" customer="SMITH" wo="123456"
qty="3" line="07">
<Station name="Label">
<WI order="1"
title="Apply Labels"
doc="10-ME40-865-7446-03-LB01-B.xml">
</WI>
</Station>
<Station name="Station1">
<WI order="1"
title="Work Instruction Test One"
doc="KB_TEST_WI1.xml">
</WI>
<WI order="2"
title="Work Instruction Test Two"
doc="KB_TEST_WI2.xml"
program="7446BRBC">
</WI>
</Station>
<Station name="Station2">
<WI order="1"
title="Work Instruction Test Three"
doc="KB_TEST_WI3.xml">
</WI>
</Station>
</Assembly>
</WorkFlow>
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest
-
DataGrid - Error #1009: Cannot access a property ormethod of a null object reference.
I am getting a runtime error when I click a button that fires the addPerson function. TypeError: Error #1009: Cannot access a property or method of... -
Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object
I've created user controls that contain listboxes that are dynamically populated from the database. In the html view of the user control... -
Returning a reference to an existing C++ object as a reference
Hi All, Given: package x; sub new { return bless {}, $_; } #-- callback() is call by the C++ class (reader_as_cpp_object) #-- whenever... -
SelectSingeNode("xpath")...how to test if null?
Hi, I'm using Dim xDoc as XmlDocument Dim xElem As xmlElement = xDoc("xpath") I then assign a variable to a value from the result node: Dim r... -
Error: ?null? is null or not an object
eloine: That is a bogus error message in that it probably refers to something you have done (or not done) on the page. So, looking in the...



Reply With Quote

