macro code for XML Fill

B

born2achieve

Dear friend,
i need to read xml and i need to fill in my excel workbook

for example
i need to loop through the xml and fill values in my EXcel Workbook the
example
for loop xmldatas
ColumnA :id
columnB :name
columnC :mark
columnD:designation
next

so like this i need to fill my excel values.can u please help me to do this
please friend

this is my xml:

<?xml version="1.0"?>
<data>
<student>
<id>1</id>
<name>Raymond</name>
<age>11</age>
<mark>0</mark>
<designation>engneer</designation>
</student>


<student><id>2</id>
<name>Moon</name>
<age>11</age>
<mark>100</mark>
<designation>blody</designation>
</student>


<student><id>3</id>
<name>Billy</name>
<age>11</age>
<mark>100</mark>
<designation>passd</designation>
</student>


<student><id>4</id>
<name>Pan</name>
<age>12</age>
<mark>80</mark>
<designation>vhonr</designation>
</student>


<student><id>5</id>
<name>Queenie</name>
<age>10</age>
<mark>90</mark>
<designation>sogjg</designation>
</student>


</data>
 
J

Joel

Look at the microsoft webpage. This method works very well. make sure you
add the References to the VBA window as instructions specify.

If this doesn't help, I can write code to perform the task.
 
J

Joel

I went back to your posting on Jan 7th. what was the results of my changes?
Did you add the references to the VBA code? did it give you any results?
Did you look at this web page (listing 9)
http://msdn2.microsoft.com/en-us/library/aa203722(office.11).aspx?

let me know what you are havving problems with and I will help. The actual
webbpage of the XML text code (use notepad to open XML page and post results).

I added activesheet in front of combox1. Also added library references as
stated below

On the Project menu, click References. Select the type libraries for
Microsoft ActiveX Data Object 2.5 (or later) and Microsoft XML 3.0.

Sub test()

Dim articleDoc As New DOMDocument
Dim sections As IXMLDOMNodeList
Dim sectionNode As IXMLDOMNode
Dim s As String
articleDoc.async = False
articleDoc.Load ("C:\temp\test\test.xml")
'Me.Caption = articleDoc.selectSingleNode("//student/name").Text

Set sections = articleDoc.selectNodes("//student")
ActiveSheet.ComboBox1.Clear

For Each sectionNode In sections
ActiveSheet.ComboBox1.AddItem
(sectionNode.selectSingleNode("name").Text)
Next
ActiveSheet.ComboBox1.ListIndex = 0

End Sub
 

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