将xpath存储在变量中,并在其他xpath语句中调用该变量
示例.xml
<Variable Name="LC_F_DPN">
<Path>//ZC_area/Block/Next_block/Variant</Path>
<Variable_type>DPN</Variable_type>
<Class_name>Point</Class_name>
</Variable>
myxslcode.xsl
<xsl:variable name="MyPath" select="//Variable/Path"/>
<xsl:value-of select="$MyPath[Index_on_line_section =current()/@VARIANT_RANK and Line_section_id =current()/$LC_ID]/../../Id"/>
</xsl:if>```
here, MyPath I couldnt able to access. I want to use the MyPath variable and fetch the values, Can someone please help me with this
我喜欢将 Powershell 脚本与 Xml Linq 一起使用
using assembly System.Xml.Linq
$filename = 'c:\temp\test.xml'
$doc = [System.Xml.Linq.XDocument]::Load($filename)
$variables = $doc.Descendants('Variable')
$lc_f_dpn = @([System.Linq.Enumerable]::Where($variables, [Func[object,boolean]]{ param($x) $x[0].Attribute('Name').Value -eq 'LC_F_DPN'}))
$path = $lc_f_dpn[0].Element('Path').value
$path