Reputation: 1523
I have a requirement to echo the XML in human-readable format to the command prompt, preferably to keep it looking EXACTLY like the XML does.
When I do
Set fs = CreateObject("Scripting.FileSystemObject")
Set fsInput = fs.OpenTextFile("\\PATH",1)
WScript.Echo fsInput.ReadAll
It gives me a singular line of text...so I assume it reads the XML as one line instead of traversing the nodes and outputting them. So this doesn't work. I've been googling for the last hour and I can't find what I need unfortunately.
Here is an example of what my XML looks like
<?xml version="1.0"?>
<Configuration Date="12/3/2012 4:32:30 PM">
<Sys_Info>
<Name>CEJHUI34</Name>
<Manufacturer>LENOVO</Manufacturer>
<Model>7826</Model>
<Serial_Number>N/A</Serial_Number>
<Operating_System>"Microsoft Windows 7"</Operating_System>
<OS_Version>"Professional "</OS_Version>
<IP_Address>1.5.1.85</IP_Address>
<CPU_per_Domain>1</CPU_per_Domain>
<CPU_Speed_MHz>6984</CPU_Speed_MHz>
<RAM>3176.45 MB</RAM>
</Sys_Info>
<Configuration-Tasks>
<task>
<name>All updates loaded</name>
<result>PASS</result>
<comment></comment>
</task>
<task>
<name>Accounts Setup</name>
<result>FAIL</result>
<comment>No Guest account</comment>
</task>
</Configuration-Tasks>
</Configuration >
Any ideas on what I can do?
Upvotes: 0
Views: 627
Reputation:
Instead of ReadAll()
, use ReadLine()
and output each line individually:
Set fs = CreateObject("Scripting.FileSystemObject")
Set fsInput = fs.OpenTextFile("\\PATH",1)
do until fsInput.AtEndOfStream
WScript.Echo fsInput.ReadLine()
loop
fsInput.Close
Upvotes: 1