Re: Variable not getting replace when read through XML

  • Thread starter Marco Shaw [MVP]
  • Start date
M

Marco Shaw [MVP]

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

Marco

"@lways" <[email protected]> wrote in message
news:[email protected]

> 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 Computer

@

@lways

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" <[email protected]> wrote in message
> news:[email protected]

> > 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 Computer

Top