我有以下xml,并且在我的生活中无法获得previous-sibling或follow-sibling工作。我试过这些没有运气。
我希望在名称属性等于“sporting”的Category元素之前得到兄弟姐妹。所以它将是我想要的Group元素。这些都不起作用:
Transaction/Animals/Dog/Boxers/Boxer/Category[@name='sporting']/preceding-sibling::
Transaction/Animals/Dog/Boxers/Boxer/Category[@name='sporting']/preceding-sibling::[1]
Transaction/Animals/Dog/Boxers/Boxer/Category[@name='sporting']/preceding-sibling::Group
甚至不能得到以前的拳击手....这些都不起作用。
Transaction/Animals/Dog/Boxers/Boxer[@name='Butch']/preceding-sibling::
Transaction/Animals/Dog/Boxers/Boxer[@name='Butch']/preceding-sibling::Boxer
Transaction/Animals/Dog/Boxers/Boxer[@name='Butch']/preceding-sibling::[1]
Transaction/Animals/Dog/Boxers/Boxer[@name='Butch']/preceding-sibling::[*]
- 感谢
<Transaction>
<Animals>
<Dog>
<Boxers>
<Boxer id="46436">
<Transaction source="kennel"/>
<Category name="local"/>
</Boxer>
<Boxer name="Spike">
<Group id="456"/>
<Category name="sporting"/>
</Boxer>
</Boxers>
</Dog>
<Dog>
<Location Storee="pet store"/>
<Boxers>
<Boxer id="345739">
<Submission Source="store"/>
<Category name="local"/>
</Boxer>
<Boxer name="Butch">
<Group id="123"/>
<Category name="sporting"/>
</Boxer>
</Boxers>
<Additional>
<EffectiveDate>2015-03-01</EffectiveDate>
<ExpirationDate>2016-03-01</ExpirationDate>
</Additional>
</Dog>
</Animals>
</Transaction>