![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | Re: howto? escape the comment character >>GetStuff|%{$b=[xml]$_;$b.item.title.#text} try '#text' GetStuff|%{$b=[xml]$_;$b.item.title.'#text'} |
My System Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||