XML and namespaces

I have navigated my first XML Powershell experience recently with no problem. It features a no namespace xml file and I have mastered xpath to get me anywhere I wish.
Today I ran get-gporeport to produce an xml file with every gpo. I thought I could do my selectnodes and select-xmls with ease. Sadly nothing happened. Google told me about namespaces.
It said, If you dont define namespaces, you cannot read a thing, you cannot dance the xml element search and retrieve.
What’s worse, google has next to nothing about bulletproof “just run this boilerplate code and then you can do selectnodes etc without a problem”.
So either I run through the text of my huge gpo xml file and pull out all this xmlns garbage or define some namespace object that will allow me to xpath with ease.
Has anyone got any decent reference or best practice, particularly with reference to the xml produced by get-gporeport?
I tried the code at [url]http://outputredirection.blogspot.com.au/2010/01/using-powershell-to-search-for-group.html[/url] and it didnt work.

David Z

A quick search and I found this:


Depending on what data you are looking for, Get-GPO will show you information in a standard Powershell format: See these methods as well:

Thanks - I saw those. None of those still have the magic code to unlock xml searching by creating the necessary namespaces. The first post I mentioned does, but it doesnt work when I try it.


I found a function on poshcode to remove xml namespaces. Worked a treat.
Its here: http://poshcode.org/1492

David Z