How to get attribute value using SelectSingleNode?

后端 未结 3 1164
野的像风
野的像风 2021-01-11 09:19

I am parsing a xml document, I need find out the gid (an attribute) value (3810).

Based on SelectSingleNode(). I found it is not easy to find the attri

3条回答
  •  一整个雨季
    2021-01-11 10:23

    The problem here was they your XPath was all wrong. You had this:

    Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]
    

    which would either select or not select the Attributes element depending on whether all the names matched up. This XPath should take you directly to the gid attribute you want:

    Attributes/AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']/@gid
    

提交回复
热议问题