Connecting Tech Pros Worldwide Forums | Help | Site Map

does this xpath query work in .Net 2.0?

dotnetnoob
Guest
 
Posts: n/a
#1: Aug 23 '06
Dim strFacilitFile As String = Func_Facilit(strJobSite)
Dim xTempltDoc As New Xml.XmlDocument
Dim xGpDoc As New Xml.XmlDocument
Dim y As Integer = 0
'Dim intNxtInstNumb As Integer = NextInstanceNumber(strJobSite)
Dim intNxtInstNumb As Integer = FacilitNxtInstNum(strFacilitFile)
Do
Dim intGpFlag As Integer
If CInt(arlsGpYN.Item(y)) = 1 Then
Dim intGpYNFlag As Integer = CInt(arlsGpYN.Item(intGpFlag))
Dim strImgsPth As String =
CStr(arlsTempltPath.Item(intGpYNFlag))
xTempltDoc.Load(strImgsPth)
xGpDoc.Load(strFacilitFile)
Dim nImported As Xml.XmlNode =
xGpDoc.ImportNode(xTempltDoc.DocumentElement, True)
Dim xNode As Xml.XmlNode =
xGpDoc.SelectSingleNode("/Facility/FacilityPages")

Dim nlDevsName As Xml.XmlNodeList =
xGpDoc.SelectNodes("Facility/FacilityPages//*[@LabelText='xxx'] |
Facility/FacilityPages//*[@ObjectName='xxx']")
Dim intDevsNameFlag As Integer = 0
Do
nlDevsName.Item(intDevsNameFlag).Value =
CStr(arlsDevName.Item(intGpYNFlag))
intDevsNameFlag += 1
Loop Until intDevsNameFlag = nlDevsName.Count

Dim nlInstNum As Xml.XmlNodeList =
xGpDoc.SelectNodes("Facility/FacilityPages//@InstanceNumber")
Dim intInstNum As Integer = intNxtInstNumb
Dim intInstNumFlag As Integer = 0
Do
If nlInstNum.Item(intInstNumFlag).InnerText =
CStr(intNxtInstNumb) Then
intInstNumFlag += 1
Else
intInstNum += 2
nlInstNum.Item(intInstNumFlag).Value =
CStr(intInstNum)
End If
intInstNumFlag += 1
Loop Until intInstNumFlag = nlInstNum.Count
xNode.AppendChild(nImported)
xGpDoc.Save(strFacilitFile)
Else
intGpFlag += 1
End If
y += 1
Loop Until y = arlsGpYN.Count

the loop for the InstanceNumber work, i was able to change those xmlnode
where the xpath query "Facility/FacilityPages//@InstanceNumber".

however this xpath query doesn't seem to work
"Facility/FacilityPages//*[@LabelText='xxx'] |
Facility/FacilityPages//*[@ObjectName='xxx']" i got Null Reference Exception
was unhandled - Object Reference not set to an instance of an object on this
line of code "Dim nlDevsName As Xml.XmlNodeList =
xGpDoc.SelectNodes("Facility/FacilityPages//*[@LabelText='xxx'] |
Facility/FacilityPages//*[@ObjectName='xxx']")".

is my xpath not working? i use Altova xmlspy and the query work under xmlspy.

Closed Thread