Windows Vista Forums

Re: Variable not getting replace when read through XML

  1. #1


    Marco Shaw [MVP] Guest

    Re: Variable not getting replace when read through XML

    Will you only have one variable to replace or could it be more than one?

    Marco



    "@lways" <lways@newsgroup> wrote in message
    news:338F4C0A-B775-4F8B-8A03-CB8397491A49@newsgroup

    > Hi,
    >
    > I have a xml and reading the content from it. But, the content has an
    > variable along with it. Is it possible to replace the variable declared
    > in
    > the script while accessing.
    >
    > Here is the example.
    >
    >
    > ---------------------------------------------------------------------------------------------------------------------------
    > Variable.xml
    > ---------------------------------------------------------------------------------------------------------------------------
    > <variable>
    > <test>
    > <branchname>
    > <port2666>testvalue_win11.2.$hfno</port2666>
    > <\branchname>
    > <\test>
    > <\variable>
    >
    >
    >
    > ---------------------------------------------------------------------------------------------------------------------------
    > Test.ps1
    > ---------------------------------------------------------------------------------------------------------------------------
    >
    > $hfno="005"
    > [xml]$xmlcontent=get-content .\Variable.xml
    >
    > echo $xmlcontent.variable.test.branchname.port2666
    >
    > ---------------------------------------------------------------------------------------------------------------------------
    > Output
    > ---------------------------------------------------------------------------------------------------------------------------
    > Actual ouput : testvalue_win11.2.$hfno
    >
    > Expected ouput : testvalue_win11.2.005
    >
    > ---------------------------------------------------------------------------------------------------------------------------
    >
    > Please let me know when i read a value from the xml which has the
    > variable,
    > how to replace that.
    >
    > Regards,
    > Harsha

      My System SpecsSystem Spec

  2. #2


    @lways Guest

    Re: Variable not getting replace when read through XML

    We could have more than one variable to be replaced

    "Marco Shaw [MVP]" wrote:

    > Will you only have one variable to replace or could it be more than one?
    >
    > Marco
    >
    > "@lways" <lways@newsgroup> wrote in message
    > news:338F4C0A-B775-4F8B-8A03-CB8397491A49@newsgroup

    > > Hi,
    > >
    > > I have a xml and reading the content from it. But, the content has an
    > > variable along with it. Is it possible to replace the variable declared
    > > in
    > > the script while accessing.
    > >
    > > Here is the example.
    > >
    > >
    > > ---------------------------------------------------------------------------------------------------------------------------
    > > Variable.xml
    > > ---------------------------------------------------------------------------------------------------------------------------
    > > <variable>
    > > <test>
    > > <branchname>
    > > <port2666>testvalue_win11.2.$hfno</port2666>
    > > <\branchname>
    > > <\test>
    > > <\variable>
    > >
    > >
    > >
    > > ---------------------------------------------------------------------------------------------------------------------------
    > > Test.ps1
    > > ---------------------------------------------------------------------------------------------------------------------------
    > >
    > > $hfno="005"
    > > [xml]$xmlcontent=get-content .\Variable.xml
    > >
    > > echo $xmlcontent.variable.test.branchname.port2666
    > >
    > > ---------------------------------------------------------------------------------------------------------------------------
    > > Output
    > > ---------------------------------------------------------------------------------------------------------------------------
    > > Actual ouput : testvalue_win11.2.$hfno
    > >
    > > Expected ouput : testvalue_win11.2.005
    > >
    > > ---------------------------------------------------------------------------------------------------------------------------
    > >
    > > Please let me know when i read a value from the xml which has the
    > > variable,
    > > how to replace that.
    > >
    > > Regards,
    > > Harsha
    >
    > .
    >

      My System SpecsSystem Spec

Re: Variable not getting replace when read through XML

Similar Threads
Thread Thread Starter Forum Replies Last Post
read strings to variable James VB Script 1 05 Sep 2009
Replace function on a variable? Kasper Nordal Lund VB Script 2 07 Jul 2008
Re: How to display a variable value in a dialog box and how to read user input? Richard Mueller [MVP] VB Script 0 20 Jun 2008
Has anyone sucessfully read the value of the $OFS variable? Bob Landau PowerShell 2 08 Jan 2008
Read-Host issue, won't store to variable when using multiple read-host lines bryan.rutkowski@gmail.com PowerShell 7 09 Feb 2007