2

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

1 Answers1

0

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
Pankaj Jaju
  • 5,371
  • 2
  • 25
  • 41
  • Thanks, I was able to get it like this: Set nodeXML = objDoc.SelectSingleNode("//ProfileSettings/Form[@name='" & frm.NAME & "']/Control[@name='" & ControlName & "']/" & Property) MsgBox nodeXML.Text – user3125278 Dec 21 '13 at 13:52