i still run into the problem of the xpath query out ever ObjectKey under the
EventSource and i have check my code and it did get the right instance number
to plug into the xpath expression. i use altova xmlspy to evaluate my xpath
expression and it show all nine EventSource under instance number 657
Can you or someone look over my code and tell me what i miss?
For a = 0 To i Step 1
Select Case cboEventEnrolls .SelectedIndex
Case a
list_EventEnrol lInstNum =
doc.SelectNodes ("//EventEnrollment/@InstanceNumber ")
For Each nEventEnrollIns tNum In list_EventEnrol lInstNum
sInstNum = nEventEnrollIns tNum.Value
ObjectKeyList =
doc.SelectNodes ("/AutomationContr ol/EventEnrollment s/EventEnrollment[@InstanceNumber ='"
+ sInstNum +
"']/EventEnrollment Properties/EventSources/EventSource/ObjectReference/@ObjectKey")
For Each ObjectKeyNode In ObjectKeyList
cboEventSources .Items.Add(Obje ctKeyNode.Inner Xml)
Next
Next
End Select
Next
and this is a fragment of the xml
<EventEnrollmen ts>
<EventEnrollmen t InstanceNumber= "675">
<BackwardRefere nces>
<Reference ObjectKey="800. 7415_316.11_311 .3702_311.1072_ 410.3729"
PropertyName="T rendEnrollments "/>
<Reference ObjectKey="800. 7415_316.11_311 .3702_311.1083_ 410.3741"
PropertyName="T rendEnrollments "/>
</BackwardReferen ces>
<EventEnrollmen tProperties AckRequired="0" EventEnable="4" EventType="64"
NotifyClass="0" NotifyType="102 5" PresentValue="0 " ToFaultText=""
ToNormalText="" ToOffNormalText ="">
<EnabledReferen ce ObjectKey="" PropertyName=""/>
<EventParameter s BitMask="0" Deadband="" HighDiffLimit=" " HighLimit=""
ListOfBitString Values="" ListOfValues="" LowDiffLimit="" LowLimit=""
ReferencedPrope rtyIncrement="1 " TimeDelay="999" TimeInterval="9 960">
<SetpointRefere nce ObjectKey="" PropertyName=""/>
</EventParameters >
<EventSources >
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 570"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 572"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 574"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 576"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 578"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 580"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e ObjectKey="800. 7415_801.101_8. 115_216.12_217. 582"
PropertyName="V aluePointProper ties.PresentVal ue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e
ObjectKey="800. 7415_801.101_8. 115_200.391_199 .392_829.1"
PropertyName="P resentValue"/>
</EventSource>
<EventSource EventState="0">
<FeedbackRefere nce ObjectKey="" PropertyName=""/>
<ObjectReferenc e
ObjectKey="800. 7415_801.101_8. 115_200.391_199 .394_829.1"
PropertyName="P resentValue"/>
</EventSource>
</EventSources>
</EventEnrollment Properties>
<GeneralPropert ies Attr="0" InstanceNumber= "675" IsConfigured="0 "
ObjectName="Pla ntHistory" ObjectType="9" SchemaVer="1.4" TraceOptions="0 ">
<Description/>
</GeneralProperti es>
</EventEnrollment >
thank you
"Martin Honnen" wrote:
dotnetnoob wrote: this is the xpath query that i use:
//EventEnrollment[@InstanceNumber ='675']//EventSources/EventSource/ObjectReference/@ObjectKey
are you saying that to query out each EventEnrollment 's InstanceNumber then
how do you place the value '675' to the prediate @InstanceNumber . i
understand that xpath query is a string but i don't understand how build that
string dynamically.
I assume that you have a variable e.g.
instanceNumber
with the number you are looking for and then you would simply build the
string using string concatenation e.g.
"//EventEnrollment[@InstanceNumber ='" + instanceNumber +
"']//EventSources/EventSource/ObjectReference/@ObjectKey"
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/