我有這樣的XML:XSLT 2.0:正則表達式提取物和修改元素值
<xml>
<row>
<image><![CDATA[javascript: open_window_zoom('http://example.com/image.php?image=/images/test/example.png&pID=46391&download=noid_90.png&name=Test name', 975, 366);]]></image>
<quantity>0</quantity>
</row>
<row>
<image><![CDATA[javascript: open_window_zoom('http://example.com/image.php?image=/images/test/another.png&pID=06395&download=anotherfile.png&name=Test name', 975, 366);]]></image>
<quantity>0</quantity>
</row>
</xml>
它可以提取pID=NUMBERHERE&download=FILENAMEHERE.png
(之前它添加新的URL)從<image>
元素?
輸出應該是這樣的:
<xml>
<row>
<image>http://newurl.com/pID=46391&download=noid_90.png</image>
<quantity>0</quantity>
</row>
<row>
<image>http://newurl.com/pID=06395&download=anotherfile.png</image>
<quantity>0</quantity>
</row>
</xml>
我嘗試了一些東西,但我不能得到desidered結果。用於起動I可以複製當前結構:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
什麼'(?<=)具有PID [^&'] +'?匹配'&pID'後面的所有內容,直到達到'&'或'''。不包括最初的&&。 –