运行此命令时:
objDoc.SelectSingleNode ("//ProfileSettings/Form[@name='frmViewMailMessages']/Control[@name='subMailMessages']/Height")
使用objDoc的XML:
<ProfileSettings>
<Form name="frmViewMailMessages">
<Control name="subMailMessages">
<Height>4175</Height>
</Control>
<Control name="subMailMessage">
<Height>4500</Height>
<Top>3975</Top>
</Control>
</Form>
</ProfileSettings>
objDoc.Text返回一个包含所有附加值的字符串:
417545003975
我正在尝试仅从frmViewMailMessages-&gt; subMailMessages-&gt;高度
接收值4175有什么想法吗?感谢
答案 0 :(得分:0)
我想我知道为什么....你使用了错误的对象。您需要将其设置为objDoc
,然后检索该值,而不是使用Node
。像下面的东西
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.SetProperty "SelectionLanguage", "XPath"
xmlDoc.Async = False
xmlDoc.Load("C:\Users\Pankaj\Desktop\test.xml")
Set nodeXML = xmlDoc.SelectSingleNode("//ProfileSettings/Form[@name='frmViewMailMessages']/Control[@name='subMailMessages']/Height")
msgbox nodeXML.Text