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

XML and VB woking together?

Status
Not open for further replies.

JeremyM

Programmer
Nov 10, 2000
33
0
0
US
I need to append a section of XML code to an existing XML document using VB. I can get everything to work EXCEPT I need to either delete the last line first or insert above the last line (which does have a unique entry in the line in case someone has an idea to search for it). Does anyone know how to specify a certain line of code in XML using VB?

Thnks,
Jeremy
 
JeremyM -

Given that XML formatting is not always one attribute or element per line, I'd be hesitant to assume the next-to-last line is the place to insert.

What I'd do (and it's unfortunately not the fastest method) is to load up your XML via the MSXML.DOMDocument loadXML() method, run through the collection of attributes until you get to where you need to insert, do the insert via the insertBefore method, and then read out the new XML via the read-only XML property.

Chip H.
 
"...and then read out the new XML via the read-only XML property."

Or perhaps use the save method of the DOMDocument... :)

But I certainly agree that DOM is the way to go here.
After you have loaded the document use the selectNodes or selectSingleNode method to localize the element and then use the insertBefore method.

Good Luck
-Mats
 
> Or perhaps use the save method of the DOMDocument... :) <

Oh sure, if you want to do it the easy way!
<g!>

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top