Tabbing an Xml File

B

bg_ie

Hi,

I'm working in VB6 and I'm processing an xml file which is tabbed as
follows -

<?xml version="1.0"?>
<Barry>
<Meta/>
<Data>
<Block Version="01">
<NODE Name="1" Value="A" Updated="false"/>
<NODE Name="3" Value="B" Updated="false"/>
<NODE Name="8" Value="B" Updated="false"/>
<NODE Name="11" Value="A" Updated="false"/>

I then process this file and I replace the Block Node as follows -

<?xml version="1.0"?>
<Barry>
<Meta/>
<Data>
<Block Version="01">
<NODE Name="1" Value="A" Updated="false"/><NODE Name="3" Value="B"
Updated="false"/><NODE Name="8" Value="B" Updated="false"/><NODE
Name="11" Value="A" Updated="false"/>

As you can see, the NODEs are no longer tabbed as they were
previously...

So the question is, how can I correct this formatting as some of the
file users edit the file in notepad and want it tabbed as before?

This is a quick idea as to how I edit the file currently

Set blockNode = xmlDocument__.selectSingleNode("Barry/Data/Block"
Set nodeList = blockNode.childNodes
Set XmlNode = xmlDocument__.createElement("Block")
Set attrName = xmlDocument__.createAttribute("Name")
attrName.Text = "1"
XmlNode.Attributes.setNamedItem attrName
blockNode.appendChild XmlNode

Thanks for your help,

Barry
 
T

Tom Shelton

Hi,

I'm working in VB6 and I'm processing an xml file which is tabbed as
follows -

<?xml version="1.0"?>
<Barry>
<Meta/>
<Data>
<Block Version="01">
<NODE Name="1" Value="A" Updated="false"/>
<NODE Name="3" Value="B" Updated="false"/>
<NODE Name="8" Value="B" Updated="false"/>
<NODE Name="11" Value="A" Updated="false"/>

I then process this file and I replace the Block Node as follows -

<?xml version="1.0"?>
<Barry>
<Meta/>
<Data>
<Block Version="01">
<NODE Name="1" Value="A" Updated="false"/><NODE Name="3" Value="B"
Updated="false"/><NODE Name="8" Value="B" Updated="false"/><NODE
Name="11" Value="A" Updated="false"/>

As you can see, the NODEs are no longer tabbed as they were
previously...

So the question is, how can I correct this formatting as some of the
file users edit the file in notepad and want it tabbed as before?

This is a quick idea as to how I edit the file currently

Set blockNode = xmlDocument__.selectSingleNode("Barry/Data/Block"

I believe that the XmlDocument object has an Indent property.... Which
is false by default.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top