Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format.Indented writing xml doc 1

Status
Not open for further replies.

mrmovie

Technical User
Oct 2, 2002
3,094
GB
Hi All,
am getting to know the DOM object better!
pulling me hair out today,
want to write an xml file and would like it to look nice and indented etc

i have seen vb.net code like

// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");

// Add a price element.
XmlElement newElem = doc.CreateElement("price");
newElem.InnerText = "10.95";
doc.DocumentElement.AppendChild(newElem);

// Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter("data.xml",null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);


wnat to do something similar but cnat figure out how to create the XmlTextWriter object.
can anyone help out with this please?
cheers
rich
 
I doubt that you can. XmlTextWriter is part of the .Net framework and as far as I know there is no way to use it from VBScript. Having said that, it wouldn't be terribly hard to write one yourself.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
thanks TTKP, stops me banging my head.
will look at sorting something myself, come to think of it i need this script to be in a dll anyway!
 
PreserveWhitespace might be of use to me...hmm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top