the problem is on this line: xObjKey.Value = str2
I test the xpath query with Altova XMLSpy and it work perfectly getting me
to that Node and all i want is to change the value of Node ObjectKey="" to
ObjectKey= 800....(number)
but i'm keep getting: "Object reference not set to an instance of an object."
this is the xml strucutre:
<EquipmentPropertiesEx>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,16
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump1Status"
Persistent="1" Value="1">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,64
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump2Status"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,112
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump3Status"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,160
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump1Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,208
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump2Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,256
80,32" DataType="integer" Enabled="1" Inner="0" Name="inPump3Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,304
80,32" DataType="float" Enabled="1" Inner="0" Name="inSetpoint1"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,352
80,32" DataType="float" Enabled="1" Inner="0" Name="inSetpoint2"
Persistent="1" Value="73">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,400
80,32" DataType="float" Enabled="1" Inner="0" Name="inSetpoint3"
Persistent="1" Value="69">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,448
80,32" DataType="integer" Enabled="1" Inner="0" Name="inTowerSelection"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,496
80,32" DataType="float" Enabled="1" Inner="0" Name="inTemp" Persistent="1"
Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,544
80,32" DataType="integer" Enabled="1" Inner="0" Name="inTwr1Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,688
80,32" DataType="integer" Enabled="1" Inner="0" Name="inTwr2Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="input" Category="" Coordinates="16,784
80,32" DataType="integer" Enabled="1" Inner="0" Name="inTwr3Failure"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,832
80,32" DataType="float" Enabled="1" Inner="0" Name="varDb1" Persistent="1"
Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,880
80,32" DataType="float" Enabled="1" Inner="0" Name="varDb2" Persistent="1"
Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,928
80,32" DataType="float" Enabled="1" Inner="0" Name="varDb3" Persistent="1"
Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,976
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart"
Persistent="1" Value="5">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1024
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart1"
Persistent="1" Value="1110820127.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1072
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart2"
Persistent="1" Value="1110820127.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1120
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart3"
Persistent="1" Value="1110820127.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1168
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart4"
Persistent="1" Value="1110820127.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1216
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeStart5"
Persistent="1" Value="1110820127.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1264
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse"
Persistent="1" Value="1110820122.788">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1312
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse1"
Persistent="1" Value="1107642785.562">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1360
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse2"
Persistent="1" Value="70.125">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1408
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse3"
Persistent="1" Value="60">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1456
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse4"
Persistent="1" Value="1107642785.562">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1504
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeElapse5"
Persistent="1" Value="25.1559998989105">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1552
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay"
Persistent="1" Value="20">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1600
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay1"
Persistent="1" Value="1107642785.562">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1648
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay2"
Persistent="1" Value="45.6399998664856">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,1696
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay3"
Persistent="1" Value="20">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,2368
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay4"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,2416
80,32" DataType="integer" Enabled="1" Inner="0" Name="varTimeDelay5"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="variable" Category="" Coordinates="16,2464
80,32" DataType="integer" Enabled="1" Inner="0" Name="varStage"
Persistent="1" Value="1">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="output" Category="" Coordinates="16,2560
80,32" DataType="integer" Enabled="1" Inner="0" Name="outTowerFan1Enable"
Persistent="1" Value="1">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="output" Category="" Coordinates="16,2608
80,32" DataType="integer" Enabled="1" Inner="0" Name="outTowerFan2Enable"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
<EquipmentProperty AccessType="output" Category="" Coordinates="16,2656
80,32" DataType="integer" Enabled="1" Inner="0" Name="outTowerFan3Enable"
Persistent="1" Value="0">
<BackwardReferences/>
<Reference ObjectKey="" PropertyName=""/>
</EquipmentProperty>
</EquipmentPropertiesEx>
<GeneralProperties Attr="1" InstanceNumber="21223" IsConfigured="0"
ObjectName="TowerFan_Control" ObjectType="203" SchemaVer="1.4"
TraceOptions="0">
<Description/>
</GeneralProperties>
</EquipmentObject>
"Martin Honnen" wrote:
>
dotnetnoob wrote:
i keep getting Object references not set to an instance of an object from
Dim xDoc As New Xml.XmlDocument
xDoc.Load(CStr(arlsFilePath.Item(x)))
Dim xNode As Xml.XmlNode =
xDoc.SelectSingleNode("/EquipmentObject/EquipmentPropertiesEx/EquipmentProperty[@Name='" + CStr(arlsVarName.Item(x)) + "']/Reference/@ObjectKey")
xNode.Value = str2
On which line do you get the error, on the line above? That means that
SelectSingleNode with the XPath expression passed in has not found a
matching node and xNode is Nothing in VB.
We would need to see the XML or relevant parts of it to be able to say
why the XPath does not find a node.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/