XSLT - Problem with foreach and incremented attribute name -


i'm using xslt , transform this:

<attr>     <header name="updateinformation1">         <detail name="info">blah</detail>     </header>      <header name="updateinformation2">         <detail name="info">blah2</detail>     </header>  ...other headers different names... </attr> 

to this:

<updateinformation>    <info>blah</info> </updateinformation> <updateinformation>    <info>blah2</info> </updateinformation> ... 

i've been trying using foreach, i'm not having success. heres have, wildcards don't work in type of context:

* wrong *

<xsl:for-each select="attr/header[@name='updateinformation*']">     <updateinformation>     <info>           <xsl:value-of select="detail[@name='info']"/>         </info>     </updateinformation> </xsl:for-each> 

* wrong *

any suggestions? thanks!

use this:

<xsl:for-each select="attr/header[starts-with(@name, 'updateinformation')]">     <updateinformation>         <info>             <xsl:value-of select="detail[@name='info']"/>         </info>     </updateinformation> </xsl:for-each> 

edited: corrected xpath expression per comments (below).


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -