我需要使用TFS的全局列表。我已经下载了它,并可以访问具有名称空间的xml。我创建了XmlNamespaceManager
,但是在获取所需节点时仍然遇到问题。对于那些不熟悉的人,TFS全球列表看起来像这样:
<gl:GLOBALLISTS xmlns:gl="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/globallists">
<GLOBALLIST name="Builds">
<LISTITEM value="..." />
</GLOBALLIST>
...
<GLOBALLIST name="Client Name">
<LISTITEM value="Test" />
将全局列表下载到XmlDocument
之后,我使用以下代码尝试提取测试节点,但返回的是空值。
Dim globalList As XmlDocument = store.ExportGlobalLists()
Dim nsManager As XmlNamespaceManager = New XmlNamespaceManager(globalList.NameTable)
nsManager.AddNamespace("gl", "http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/globallists")
Dim node As XmlNode = globalList.SelectSingleNode("//gl:GLOBALLISTS/gl:GLOBALLIST[@name='Client Name']/gl:LISTITEM[@value='" + Name + "']", nsManager)
作为旁注,我正在搜索的名称确实存在。我还在即时窗口中尝试了以下方法:
globalList.SelectNodes("/gl:GLOBALLISTS", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("//gl:GLOBALLISTS/gl:GLOBALLIST[name='Client Name']/gl:LISTITEM[value='" + Name + "']", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("//gl:GLOBALLIST[name='Client Name']/gl:LISTITEM[value='" + Name + "']", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("//gl:GLOBALLIST[name='Client Name']", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("//gl:GLOBALLIST", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("//gl:GLOBALLISTS/GLOBALLIST[name='Client Name']/LISTITEM[value='Test']", nsManager)
Expression has been evaluated and has no value
globalList.SelectSingleNode("/gl:GLOBALLISTS/gl:GLOBALLIST[@name='Client Name']/gl:LISTITEM[@value='" + Name + "']", nsManager)
Expression has been evaluated and has no value
解决方案
除了第一个节点外,我必须取出名称空间引用,并按照下面的答案中的建议添加@符号以访问属性。
Dim node As XmlNode = globalList.SelectSingleNode("//gl:GLOBALLISTS/GLOBALLIST[@name='Client Name']/LISTITEM[@value='" + Name + "']", nsManager)
答案 0 :(得分:1)
在XPath中,使用html .inputHighlightText:focus
{
overflow: hidden!important;
-webkit-overflow: hidden!important;
-moz-overflow: hidden!important;
-o-overflow: hidden!important;
-ms-overflow: hidden!important;
}
this.preventDefault = function(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
this.disable_scroll_mobile = function(el = null){
if(el !== null) {
$(el).focus((e) => {
e.preventDefault();
});
}
$("body").css("overflow", "hidden!important");
$("#fullScreenBg").css("overflow", "hidden!important");
$(window).css("overflow", "hidden!important");
window.addEventListener('touchmove',$self.preventDefault, false);
document.addEventListener('touchmove',$self.preventDefault, false);
window.addEventListener('scroll',$self.preventDefault, false);
document.addEventListener('scroll',$self.preventDefault, false);
}
this.enable_scroll_mobile = function(){
$("body").css("overflow", "scroll");
$("#fullScreenBg").css("overflow", "scroll");
$(window).css("overflow", "scroll");
window.removeEventListener('touchmove',$self.preventDefault, false);
document.removeEventListener('touchmove',$self.preventDefault, false);
window.removeEventListener('scroll',$self.preventDefault, false);
document.removeEventListener('scroll',$self.preventDefault, false);
}
this.disable_scroll_mobile();
指示属性。这似乎是您遇到问题的原因,因为您没有使用@
。
此外,正如您自己发现的那样,只有最外面的元素位于名称空间中,因此只有第一段应具有@
。
gl: