473,398 Members | 2,343 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,398 software developers and data experts.

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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
0 1222

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

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
1
by: Murtaza Tinwala | last post by:
Hi mates, I have the following problem in XSLT. I have following variables: ref-file = <path of XML document> eg "xmlDoc.xml" repeatpath = <a repeat path expressed in Xpath like /root/person >...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
0
by: anthony.raj | last post by:
Hi, I have an XML Datasource in the following format - <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> <table> <event > <field name="user" value="anthony"/> <field name="date"...
1
by: andy | last post by:
I am using XPath for the Electric XML Parser and having trouble getting simple XPath queries to work. The following query works: document.getElement(new...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
1
by: Hollywood | last post by:
I have the following XSD created in VS.NET 2003: <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="ReferralSchama" targetNamespace="http://test.org/Referral"...
1
by: rob willaar | last post by:
Hi all. The following xpath select returns three nodes but i want to select only the node where the 'appupdate' has attribute 'version=01' There is lotsof info and samples but i can't find the...
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
3
by: Arndt Jonasson | last post by:
Let's say we have a schema (maybe expressed in XML Schema, but not necessarily so), that allows this instance document: <top> <txt>This is text</txt> <books> <book>Tarzan</book> <book>Harry...
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.