Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

writing output to XML file

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 02-15-2007   #1 (permalink)
Nikhil R. Bhandari
Guest


 

writing output to XML file

I have a log file and I have convert it into a xml file.

Log file :
======================================
Machine Details
Computer Name : ABCD-101
UserName : test
Domain : WORKGROUP
IP Address : xxx.xx.xx.xx
OS : Microsoft Windows XP Professional - Service Pack 2
....
Product Information
Product : XYZ
Version : 1.0.1
InstallDate : 20061222
....
======================================

And I want to convert it to xml file with following format,

======================================
<?xml version="1.0" ?>
<MyXml>
<MachineDetails>
<ComputerName>ABCD-101</ComputerName>
<UserName>test</UserName>
<Domain>WORKGROUP</Domain>
<IP Address >xxx.xx.xx.xx</IP Address >
<OS>Microsoft Windows XP Professional - Service Pack 2</OS>
</MachineDetails>
<ProductInfo>
<Product>XYZ</Product>
<Version>1.0.1</Version>
<InstallDate >20061222</InstallDate >
</ProductInfo>
</MyXml>
======================================

The one way I can think of is to use use Get-Content to get all the data
from log file and use SPLIT to split the line with ":" as separator. Then
compose a line using tags and data & use OUT-FILE to write to a file.

Is there any better way to create a XML file?



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Writing file to CD cjamps .NET General 1 08-18-2008 10:26 PM
writing out to file Braden C. Roberson-Mailloux PowerShell 3 05-18-2008 01:12 PM
Re: Writing output to a formatted file Keith Hill [MVP] PowerShell 0 11-08-2007 08:49 PM
Writing to host in functions and cmdlets - how to capture this output Keith Hill [MVP] PowerShell 1 12-30-2006 03:54 PM
Writing to a file with out-file or export-csv Marco Shaw PowerShell 1 11-07-2006 02:44 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com 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 2005-2008