Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - howto? escape the comment character

Reply
 
Old 11-01-2006   #1 (permalink)
public news groups


 
 

howto? escape the comment character

While working with some xml, I find I want to get to the '#text' property of
a node. Can anyone give me a hint?

this obviously fails since '#' is the comment character
>GetStuff|%{$b=[xml]$_;$b.item.title.#text}

Missing property name after '.' operator.
>


backtick '`' doesn't do the job
>GetStuff|%{$b=[xml]$_;$b.item.title.`#text}

....missing of invalid property reference
>


the property exists
>GetStuff|%{$b=[xml]$_;$b.item.title}

cf type #text
-- ---- -----
http://www.mic... text The content of the tag
....
>




My System SpecsSystem Spec
Old 11-01-2006   #2 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: howto? escape the comment character

I can't test this off right now, but off the top of my head I would say the
answer is to quote it - which is quite legal in PowerShell:

GetStuff|%{$b=[xml]$_;$b.item.title."#text"}


"public news groups" <null@nil.no> wrote in message
news:ukS$jjh$GHA.3536@TK2MSFTNGP04.phx.gbl...
> While working with some xml, I find I want to get to the '#text' property
> of a node. Can anyone give me a hint?
>
> this obviously fails since '#' is the comment character
>>GetStuff|%{$b=[xml]$_;$b.item.title.#text}

> Missing property name after '.' operator.
>>

>
> backtick '`' doesn't do the job
>>GetStuff|%{$b=[xml]$_;$b.item.title.`#text}

> ...missing of invalid property reference
>>

>
> the property exists
>>GetStuff|%{$b=[xml]$_;$b.item.title}

> cf type #text
> -- ---- -----
> http://www.mic... text The content of the tag
> ...
>>

>
>



My System SpecsSystem Spec
Old 11-02-2006   #3 (permalink)
xshell


 
 

Re: howto? escape the comment character


>>GetStuff|%{$b=[xml]$_;$b.item.title.#text}


try '#text'

GetStuff|%{$b=[xml]$_;$b.item.title.'#text'}


My System SpecsSystem Spec
Old 11-02-2006   #4 (permalink)
public news groups


 
 

Re: howto? escape the comment character

Thanks. I have no reason why I didn't try that. I was fixated on escaping
it.


"Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote
>...off the top of my head I would say the answer is to quote it - which is
>quite legal in PowerShell:
>
> GetStuff|%{$b=[xml]$_;$b.item.title."#text"}



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: exchange shell escape character PowerShell
Escape character question PowerShell
How can I escape a slash character in item name? PowerShell
How do I escape the wildcard character in a path string? PowerShell
Bug in escape character / variable expansion? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46