using variable as attribute in xpath expression - wrong group?

K

KathyB

Hi, I'm using the following xmlDocument and xpath to load a file using
a variable.

I've tried several renditions of the xpath using the variable but
without success (error: object variable not set). If I hardcode it as
[@name="Label"] it works so I know the xpath is ok, except for the
variable syntax?

Any hints appreciated. Thanks, kathy

Code:

Dim strStation As String = "Label" 'ultimately need var set from
control
Dim xDoc As New XmlDocument()
xDoc.Load(Server.MapPath("test.xml"))
Dim xNode = xNode.SelectSingleNode("/WorkFlow/Assembly/Station[@name='"
& strStation & "']/WI[1]/@doc")
Dim strWI As String = xDoc.InnerText.ToString()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top