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

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top