Question

When running this command:

objDoc.SelectSingleNode ("//ProfileSettings/Form[@name='frmViewMailMessages']/Control[@name='subMailMessages']/Height")

With objDoc's XML being:

<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 returns a string containing all values appended:

417545003975

I'm trying to only receive the value 4175 from frmViewMailMessages->subMailMessages->Height

Any ideas? Thanks

Was it helpful?

Solution

I think i know why .... you are using wrong object. Instead of using the objDoc, you need to set this into a Node and then retrieve the value. Something like the below

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top