0
如果myVariable = "Element"
然後給我那個元素中的屬性。來自特定元素節點的XML抓取屬性
XML:
<Products>
<Equity>
<servers>
<serverEQ>server1</serverEQ>
<serverEQ>server2</serverEQ>
<serverEQ>server3</serverEQ>
</servers>
<sitesE>
<sitesEQ sitePathEQ="\Logs\W3SVC1"><nameEQ>SystemAdmin Site</nameEQ></sitesEQ>
<sitesEQ sitePathEQ="\Logs\W3SVC3"><nameEQ>Direct Access Site</nameEQ></sitesEQ>
<sitesEQ sitePathEQ="\Logs\W3SVC4"><nameEQ>Redirect Site</nameEQ></sitesEQ>
<sitesEQ sitePathEQ="\Logs\W3SVC5"><nameEQ>Download Site</nameEQ></sitesEQ>
</sitesE>
</Equity>
.
.
.
</Products>
例如:如果myVariable = "Direct Access Site"
給我\Logs\W3SVC3
作爲我的輸出。
我發現侯賽因Narimani Rad公司的回答最有用的。謝謝 – SlopTonio