XML Dotted Notation - using a variable RRS feed

  • Question

  • My goal is to have a variable hold the dotted notation path to an element.  I hope this is just a syntax issue.  In the snippet below, the first line gives me the result I want.

    I'm trying to figure out how to get the third line to work.

    $colElements = $xmlFileL.configuration."system.serviceModel".client.endpoint
    $Var1 = 'configuration."system.serviceModel".client.endpoint'
    $colElements = $xmlFileL.$Var1

    Wednesday, February 12, 2020 8:24 PM

All replies

  • That cannot be done. 

    This is how to do this:

    #with variable:
    $xpath = '//configuration/system/serviceModel/client/endpoint'

    Of course you may have to resolve namespaces and you can use an iterative "where-object' to search for nodes.


    Wednesday, February 12, 2020 8:55 PM