xsl:for-each test a wildcard element
我试图遍历一些XML,直到找到包含文本字符串的元素。
举一个非常简单的XML示例。
1 2 3 4 5 6 7 8 9 10 | <document> <item> <thing1>Fee</thing1> <thing2>Fi</thing2> <thing3>Fo</thing3> <some blah="Thingy">Fum</some> I Smell</another> <other>Someone</other> </item> </document> |
我希望能够搜索包含"事物"的任何元素,我之前已经看过使用诸如...这样的属性来完成此操作...
1 | <xsl:for-each test="contains(@blah,'Thingy')"></xsl:for-each> |
但是我想搜索" thing1,thing2,thing3",然后获取它们的
尝试:
1 | <xsl:for-each select="*[contains(name(), 'thing')]"> |
或者,以更好地适应给定的示例:
1 | <xsl:for-each select="*[starts-with(name(), 'thing')]"> |
两者均从