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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML DOM in VB 6.0

Status
Not open for further replies.

bkowlagi

Programmer
Apr 8, 2003
28
US
I am trying to manipulate a XML DOM document using the DomDocument40 object that comes with MSXML 4.0

Right now I am able to read information of the nodes and attributes using the IXMLDOMELEMENT object. However when I try to write to the attribute using '.setattribute' it seems like the format is lost.

I was wondering if the it has anyhting to do with the documents encoding in unicode or something like that. How do I find out if the document is not encoded in ASCII and how do I write strings using different encoding formats.

e.g.
ª+1 Post Point Events
ª+2 Event Event: Paycalculate
@@

The above piece of text when written into the XML document turns up as following

ª+1 Post Point Events
 ª+2 Event Event: Paycalculate
 ª+3 Get GridP
@@


The vbNewline or vbCrlf is written as 


Any help is welcome.

 
XML doesn't use newlines, tabs or carriage-returns. People put them in to make it easier for humans to read, but the software will ignore them or strip them out.

This is because XML parsers look for elements, and do not read XML files "line by line" like you would for a CSV file. If you've got someone who is demanding that you put them in -- tell them to buy a copy of XML Spy, or to use a XML parser (like the MS-XML 4.0 library) to read their files. Note: Using Internet Explorer to view XML files is OK, but not the best solution.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
I am able to read the XML file and get the nodes and attributes I want. The problem is when I try to change the value of an attribute node. All XML parsers or writers are only concerned about XML syntax, never the values of nodes or attributes. You can have any value within quotes.

All I want to do is preserve the format of the XML file when I write into it so that the application that created the file in the first place is able to read it again.

XML spy is good and I use it too to create XML files manually. But I have to read and write XML files using VB 6.0

 
All I want to do is preserve the format of the XML file when I write into it so that the application that created the file in the first place is able to read it again.

That's what a XML parser *doesn't* do. Formatting is for humans. Content is for parsers.

If changing this breaks the other application, then the other application is badly written. Given that it's not a perfect world, you would need to write a post-processor that scans your .xml file and inserts carriage-returns at the proper place. Yuck.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top