How to Read XML file and to add some information into it

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 12
Reputation: karthiknv is an unknown quantity at this point 
Solved Threads: 0
karthiknv karthiknv is offline Offline
Newbie Poster

How to Read XML file and to add some information into it

 
0
  #1
Jul 4th, 2008
Hi,
I have a problem.
I need to read some data from a text file and need to put it into XML file using VB6.

I have the follwoing input from the text file:

Suite id="ADD"
description="Add Validation Suite"
TestCase id="ATC_V_Add001"
and so on..........

and I want the following format in XML file. I have to update the XML file with the following info:

<?xml-stylesheet type="text/xsl" href="TestSuite.xsl"?>
<LLD>
<Cycle>
<Suite id="ADD" description="Add Validation Suite">
<TestCase id="ATC_V_Add001" description="Verify the Rulecode ADD001 with Address Overlap in the same Zone or City exception">
<LinkPVID>54221487</LinkPVID>

<Results>Exception ADD001 is generated see details in Exception info section</Results>

<StepTable id="StartUpApplication" description="To launch the application" />

</TestCase>
</Suite>
</Cycle>
</LLD>
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: How to Read XML file and to add some information into it

 
0
  #2
Jul 4th, 2008
Hi,
You can use Microsoft XML, Version 2.0 or any to parse XML FIles.
Include Microsoft XML, Version 2.0 or any Type Library in to your project

> Project > Reference > Microsoft XML, Version 2.0 or any version
This below link will help u
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
KSG
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: karthiknv is an unknown quantity at this point 
Solved Threads: 0
karthiknv karthiknv is offline Offline
Newbie Poster

Re: How to Read XML file and to add some information into it

 
0
  #3
Jul 7th, 2008
Hi,
Could you tell me how to select a node having a attribute. In the example

<Suite id="ADD" description="Add Validation Suite">
How to select the Suite node using the "id' value.

Thanks,
karthik
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: How to Read XML file and to add some information into it

 
0
  #4
Jul 7th, 2008
This Code select the ID Node. Save your xml in C:\Test.xml or Change the Name in Load () function.
I am not correct exactly. but it will do.
  1. Dim xDOM As DOMDocument
  2. Set xDOM = New DOMDocument
  3.  
  4. Dim xRoot As IXMLDOMElement
  5. Dim xNodeList As IXMLDOMNodeList
  6. Dim xNM As IXMLDOMNamedNodeMap
  7. Dim xID As IXMLDOMNode
  8. xDOM.Load "c:\test.xml" ' Or your File Name
  9.  
  10. Set xRoot = xDOM.documentElement
  11. Set xNodeList = xRoot.getElementsByTagName("Suite")
  12.  
  13. If (Not xNodeList Is Nothing) Then
  14. Set xNM = xNodeList(0).Attributes
  15. Set xID = xNM.getNamedItem("id")
  16. MsgBox iM.Text
  17. End If
Last edited by selvaganapathy; Jul 7th, 2008 at 11:47 pm.
KSG
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: karthiknv is an unknown quantity at this point 
Solved Threads: 0
karthiknv karthiknv is offline Offline
Newbie Poster

Re: How to Read XML file and to add some information into it

 
0
  #5
Jul 8th, 2008
Sorry, i forgot to mention my exact requirement
i need to select the node with the value of id

Eg:To select the "Suite" node with "id "value="ADD" and need to add some more node under it

Thanks,
Karthik
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC