error loading xml file

hello,

the $xml loaded the xml file and it did store the xml as a property, but
it won't display on screen.
i need some help navigate out of the dark
many thanks



PSH �� $xml = new xml
PSH �� $xml.load("h:\windowspowershell\template.xml")
PSH �� $xml
format-default : Object reference not set to an instance of an object.
+ CategoryInfo : NotSpecified: (:) [format-default], NullReferenceException
+ FullyQualifiedErrorId :
System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand

0
ryan
2/21/2010 12:28:35 PM
windows.powershell 690 articles. 0 followers. Follow

5 Replies
1520 Views

Similar Articles

[PageSpeed] 18

Not 100% sure what you are trying to do here but for a start I don't 
understand your line 

$xml = new xml

If you want to load an xml document I would do this

[xml]$xml = Get-Content -Path c:\scripts\xml\recipe.xml

which will give you an xmldocument object to work with.  If you just want to 
display the contents then its easier

Get-Content -Path c:\scripts\xml\recipe.xml

-- 
Richard Siddaway
All scripts are supplied "as is" and with no warranty 
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"ryan" wrote:

> hello,
> 
> the $xml loaded the xml file and it did store the xml as a property, but
> it won't display on screen.
> i need some help navigate out of the dark
> many thanks
> 
> 
> 
> PSH → $xml = new xml
> PSH → $xml.load("h:\windowspowershell\template.xml")
> PSH → $xml
> format-default : Object reference not set to an instance of an object.
> + CategoryInfo : NotSpecified: (:) [format-default], NullReferenceException
> + FullyQualifiedErrorId :
> System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand
> 
> .
> 
0
Utf
2/21/2010 3:34:01 PM
i tried both. and they all work except that neither post the content on
screen

On 2/21/2010 11:34 PM, RichS [MVP] wrote:
> Not 100% sure what you are trying to do here but for a start I don't 
> understand your line 
>
> $xml = new xml
>
> If you want to load an xml document I would do this
>
> [xml]$xml = Get-Content -Path c:\scripts\xml\recipe.xml
>
> which will give you an xmldocument object to work with.  If you just want to 
> display the contents then its easier
>
> Get-Content -Path c:\scripts\xml\recipe.xml
>
>   
0
ryan
2/21/2010 4:20:48 PM
What version of PowerShell are you using?  Can you share the XML data/file 
here?

Marco

"ryan" <ryanlihk@hotmail.com> wrote in message 
news:elO4RFvsKHA.732@TK2MSFTNGP06.phx.gbl...
> hello,
>
> the $xml loaded the xml file and it did store the xml as a property, but
> it won't display on screen.
> i need some help navigate out of the dark
> many thanks
>
>
>
> PSH �� $xml = new xml
> PSH �� $xml.load("h:\windowspowershell\template.xml")
> PSH �� $xml
> format-default : Object reference not set to an instance of an object.
> + CategoryInfo : NotSpecified: (:) [format-default], 
> NullReferenceException
> + FullyQualifiedErrorId :
> System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand
> 
0
Marco
2/22/2010 12:53:43 AM
sorry. i had formatted the hdd and re-install everything. i guess i
corrupted ps when i set remoting. the code worked fine before corruption
and after the re-install. i tried setup the remoting among a rc 7, the
retail 7, and the xp (v2 ctp 3).

On 02-22-2010 8:53 AM, Marco Shaw [MVP] wrote:
> What version of PowerShell are you using?  Can you share the XML 
> data/file here?
> 
> Marco
> 
> "ryan" <ryanlihk@hotmail.com> wrote in message 
> news:elO4RFvsKHA.732@TK2MSFTNGP06.phx.gbl...
>> hello,
>>
>> the $xml loaded the xml file and it did store the xml as a property, but
>> it won't display on screen.
>> i need some help navigate out of the dark
>> many thanks
>>
>>
>>
>> PSH �� $xml = new xml
>> PSH �� $xml.load("h:\windowspowershell\template.xml")
>> PSH �� $xml
>> format-default : Object reference not set to an instance of an object.
>> + CategoryInfo : NotSpecified: (:) [format-default], 
>> NullReferenceException
>> + FullyQualifiedErrorId :
>> System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand 
>>
>>

0
ryan
2/23/2010 10:29:04 AM
Not sure that remoting scenario will work as you are dealing with different 
versions of wsman
-- 
Richard Siddaway
All scripts are supplied "as is" and with no warranty 
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"ryan" wrote:

> sorry. i had formatted the hdd and re-install everything. i guess i
> corrupted ps when i set remoting. the code worked fine before corruption
> and after the re-install. i tried setup the remoting among a rc 7, the
> retail 7, and the xp (v2 ctp 3).
> 
> On 02-22-2010 8:53 AM, Marco Shaw [MVP] wrote:
> > What version of PowerShell are you using?  Can you share the XML 
> > data/file here?
> > 
> > Marco
> > 
> > "ryan" <ryanlihk@hotmail.com> wrote in message 
> > news:elO4RFvsKHA.732@TK2MSFTNGP06.phx.gbl...
> >> hello,
> >>
> >> the $xml loaded the xml file and it did store the xml as a property, but
> >> it won't display on screen.
> >> i need some help navigate out of the dark
> >> many thanks
> >>
> >>
> >>
> >> PSH → $xml = new xml
> >> PSH → $xml.load("h:\windowspowershell\template.xml")
> >> PSH → $xml
> >> format-default : Object reference not set to an instance of an object.
> >> + CategoryInfo : NotSpecified: (:) [format-default], 
> >> NullReferenceException
> >> + FullyQualifiedErrorId :
> >> System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand 
> >>
> >>
> 
> .
> 
0
Utf
2/23/2010 7:24:01 PM
Reply:

Similar Artilces: