我是一个绝对的菜鸟,所以请原谅我没有使用正确的术语,但我会尽量精确和详细。
我使用以下表达式来获得事件" HPI-White"。有没有办法从--- SAMPLE CODE中选择另一种颜色,而不必创建单独的表达式?我可以在/ Occurence [1]之后更改#值以获得我想要的但是这似乎是多余的。
/XMLReport/Report/PreflightResult/PreflightResultEntry[3]/PreflightResultEntryMessage/StringContext/Occurences/Occurence[1]/VarPairs/VarPair[1]/VarValue/text()
---示例代码---
<PreflightResultEntryMessage xml:lang="en-US">
<Message>Spot color Dieline, HPI-White, PANTONE 105 C, PANTONE 127 C, PANTONE 7636 C, PANTONE Black C, PANTONE Blue 0821 C, PANTONE Magenta 0521 C, PANTONE Rhodamine Red C, PANTONE Warm Red C, PANTONE Yellow C is used (11x on page 1)</Message>
<StringContext>
<BaseString>Spot color %[]SpotColorName% is used</BaseString>
<ConstantPairs>
<ConstantPair>
<ConstantName>Category</ConstantName>
<ConstantValue>Check</ConstantValue>
</ConstantPair>
<ConstantPair>
<ConstantName>ActionID</ConstantName>
<ConstantValue>2078</ConstantValue>
</ConstantPair>
</ConstantPairs>
<Occurences>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>HPI-White</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="289.431" maxY="421.867" minX="89.431" minY="400.603" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Yellow C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="68.076" maxY="386.523" minX="50.717" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Warm Red C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="99.352" maxY="386.523" minX="81.993" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Rhodamine Red C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="130.628" maxY="386.523" minX="113.269" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Magenta 0521 C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="161.904" maxY="386.523" minX="144.545" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Blue 0821 C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="193.18" maxY="386.523" minX="175.821" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE Black C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="224.455" maxY="386.523" minX="207.096" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE 105 C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="255.731" maxY="386.523" minX="238.372" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE 127 C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="287.007" maxY="386.523" minX="269.648" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>PANTONE 7636 C</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="318.283" maxY="386.523" minX="300.924" minY="365.259" page="0"/>
</Occurence>
<Occurence>
<VarPairs>
<VarPair>
<VarName>SpotColorName</VarName>
<VarValue>Dieline</VarValue>
</VarPair>
<VarPair>
<VarName>Instances</VarName>
<VarValue>0</VarValue>
</VarPair>
</VarPairs>
<Location maxX="364.928" maxY="472.927" minX="4.0725" minY="4.0722" page="0"/>
</Occurence>
</Occurences>
</StringContext>
</PreflightResultEntryMessage>
答案 0 :(得分:0)
嗯,简短的回答是用Occurence[1]
替换Occurence
。然后你会得到以下文字:
HPI-WhitePANTONE Yellow CPANTONE Warm Red CPANTONE Rhodamine Red CPANTONE Magenta 0521 CPANTONE Blue 0821 CPANTONE Black CPANTONE 105 CPANTONE 127 CPANTONE 7636 CDieline
可能不是你想要的。
所以让我们谈谈XPath。其目的是从XML文档中选择一组节点。所选节点可以是文本节点,但一般来说,其想法是返回节点集并将其返回给您进行处理。因此,很多事情将取决于您使用XPath的工具,以及在您提供节点集时可以使用的节点集。你在使用什么XPath? XSLT?蟒蛇? PHP?