# Xml powershell

How to open an xml file with powershell.
###### Who is Participating?

Commented:
I've already shown methods for how to load an xml file.

To save the file you can use
$xml.Save($file)


This link includes info on working with xml files, including how to edit data.
Exact syntax depends on your xml file.

If you can't provide specifics, then there's nothing more we can contribute here.  Sorry, but you're only providing partial answers to each question.  It's far too much work to provide info to cover every situation, so you need to provide much more detail.
0

Author Commented:
I am getting this error:
Missing equals sign between attribute and attribute value when I try to
$ObjXmlFile.GetCharArray() 0 Commented: There are different ways to open an XML file. #performs best$file = "C:\path\to\file.xml"
$xml = New-Object -TypeName System.Xml.XmlDocument$xml.Load($file) #or$file = "C:\path\to\file.xml"
$xml = [xml](Get-Content$file)

# if the file is output from Export-CliXml
$file = "C:\path\to\file.xml"$xml = Import-CliXml $file  I have no idea where you're getting that error. You haven't shown what$objxmlfile is.
0

Author Commented:
Thanks, I am trying to retrieve a xml file which is an webfile.
Using importsocument function
0

ConsultantCommented:
$ObjXmlFile.GetCharArray() is an expression that returns a value. it should look like:$a = $ObjXmlFile.GetCharArray() 0 Author Commented: Exactly its teturnung the error as mentioned 0 Batchelor, Developer and EE Topic AdvisorCommented: Are you able to display the file in e.g. IE as XML? 0 Commented: I'm wondering how$ObjXmlFile was actually created/instantiated because GetCharArray() is not a method for the type System.Xml.XmlDocument.  Please show complete (relevant) code.

What exactly are you trying to do?
0

Author Commented:
Footech,
I am trying to read an xml file and need to edit values in it.
Its a normal xml file and if you could provide me the reference on how to read xml file line by line and alter the values in it , will be very helpful.

Thanks
0

Author Commented:
Thanks Footech!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.