首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XPath,获取XML元素中的下一个属性

XPath,获取XML元素中的下一个属性
EN

Stack Overflow用户
提问于 2016-12-06 04:29:23
回答 2查看 118关注 0票数 1

此XPath表达式//groups/groupInformation/@ groupID包含(.,'10300')执行从groupID获取"10300“的工作(见下文)。但是,如何从groupName、groupDescription等获取文本呢?想要检索"Carnell - Brown“等等。当我描述这个问题时,我不确定我是否正确地使用了"element“和"attribute”。

代码语言:javascript
复制
<groupInformation groupID="10300" groupName="Carnell - Brown" groupDescription="The comfortable contemporary design of the “Carnell-Walnut” upholstery collection features deeply stitched back cushioning and shaped chaise seating all surrounded with soft faux leather fabric which offers the beauty and character of leather to create the ultimate collection for any home." groupStyle="Contemporary" groupFeatures="Frame constructions have been tested with various equipment to simulate the home and transportation environments to insure durability. Corners are glued, blocked and stapled. All fabrics are pre-approved for wearability and durability against AHFA standards. Cushion cores are constructed of low melt fiber wrapped over high quality foam. Features metal drop-in unitized seat box for strength and durability. All metal construction to the floor for strength and durability. The reclining mechanism features infinite positions for comfort. Heavyweight faux leather upholstery fabric. Jumbo thread stitched detailing. Collection features the option of either power or non-power pieces." />
EN

回答 2

Stack Overflow用户

发布于 2016-12-06 05:38:15

而不是回答here

代码语言:javascript
复制
//groups/groupInformation/@groupID[contains(., '10300')]/parent::*/@groupName

我建议,

代码语言:javascript
复制
//groups/groupInformation[@groupID='10300']/@groupName

因为

@groupID为10300999或9991030时,

  • It's more concise.
  • You'll避免错误匹配...
票数 2
EN

Stack Overflow用户

发布于 2016-12-06 05:28:02

这样做://groups/groupInformation/@groups包含(.,'10300')/parent::*/@groupName

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40982760

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档