Click here to Skip to main content
14,737,119 members
Home » Discussions » XML / XSL
   

XML / XSL

 
GeneralRe: XSL: how to properly reference to xml field? Pin
Maciej Los17-Nov-14 5:25
mveMaciej Los17-Nov-14 5:25 
QuestionHow to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire30-Oct-14 4:53
professionalJohn Whitmire30-Oct-14 4:53 
AnswerRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
Gerry Schmitz30-Oct-14 22:21
mveGerry Schmitz30-Oct-14 22:21 
GeneralRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire3-Nov-14 4:04
professionalJohn Whitmire3-Nov-14 4:04 
SuggestionRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire6-Nov-14 3:47
professionalJohn Whitmire6-Nov-14 3:47 
QuestionVB.NET creat new XML Pin
Dereak12-Oct-14 18:43
MemberDereak12-Oct-14 18:43 
AnswerRe: VB.NET creat new XML Pin
User 41802545-Aug-15 3:28
MemberUser 41802545-Aug-15 3:28 
QuestionWriting XML from Excel Using VBA Pin
gedkins@deltagl.com30-Sep-14 15:15
Membergedkins@deltagl.com30-Sep-14 15:15 
I have some data in Excel which represents structured lists to be imported into a SQL database in an XML format. I am not so familiar with the nuances of XML but I am pretty good with VBA. I need to generate an XML file that looks like this.

<?xml version="1.0"?>

<!DOCTYPE xml>

<!--To use the dtd in an external file: <!DOCTYPE xml SYSTEM "filename.dtd">-->

-<xml>


-<transactions>


-<transaction vaultname="Type in the name of the vault here" date="123459" type="import_lists">

<!-- Just a list without links -->



-<list name="Materials">

<item item_name="Ceramic"/>

<item item_name="Ferrous Metal"/>

<item item_name="Nonferrous Metal"/>

<item item_name="Superalloy"/>

</list>

<!-- A set of linked lists -->



-<list name="Ceramics">

<item item_name="Boride"/>

<item item_name="Carbide"/>

<item item_name="Nitride"/>

<link link_value="Ceramic" list_variable="Material Type" source_variable="My Material"/>

</list>


-<list name="Ferrous Metals">

<item item_name="Stainless Steel"/>

<item item_name="Carbon Steel"/>

<item item_name="Tool Steel"/>

<link link_value="Ferrous Metal" list_variable="Material Type" source_variable="My Material"/>

</list>


-<list name="Nonferrous Metals">

<item item_name="Aluminium Alloy"/>

<item item_name="Copper Alloy"/>

<item item_name="Tin Alloy"/>

<link link_value="Nonferrous Metal" list_variable="Material Type" source_variable="My Material"/>

</list>


-<list name="Superalloys">

<item item_name="Cobalt Base"/>

<item item_name="Iron Base"/>

<item item_name="Nickel base"/>

<link link_value="Superalloy" list_variable="Material Type" source_variable="My Material"/>

</list>

</transaction>

</transactions>

</xml>


I have the data in Excel and I would like to use VBA code similar to the below, but I am having a devil of a time getting it to output as shown above. When I change the tags to what I need in the sample output the result is just a mess. I am sure its my limited exposure to XML that has me stumbling. If someone could show me a sample set of the VBA that would output some of the above it would get me rolling again.

Dim FSO As Object
     Dim NewFile As Object
     Dim FullPath As String
     Dim XMLFileText As String

     FullPath = "C:\Users\Administrator\Desktop\Guy2.xml"
     'On Error GoTo Err:

     Set FSO = CreateObject("Scripting.FileSystemObject")
     Set NewFile = FSO.CreateTextFile(FullPath, 1, 1)

     XMLFileText = ""
     XMLFileText = XMLFileText & "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>" & vbNewLine
     XMLFileText = XMLFileText & "<DATAROOT>" & vbNewLine
     NewFile.Write (XMLFileText)


     'Data in Excell files
     XMLFileText = "<DATA>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<c10>" & Range("C10") & "</c10>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<D10>" & Range("D10") & "</D10>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<E10>" & Range("E10") & "</E10>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "</DATA>" & vbNewLine
     NewFile.Write (XMLFileText)

     ' Each element
     XMLFileText = "<DATA>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<C11>" & Range("C11") & "</C11>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<D11>" & Range("D11") & "</D11>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "<E11>" & Range("E11") & "</E11>" & vbNewLine
     NewFile.Write (XMLFileText)

     XMLFileText = "</DATA>" & vbNewLine
     NewFile.Write (XMLFileText)



     XMLFileText = "</DATAROOT>" & vbNewLine

     NewFile.Write (XMLFileText)

     NewFile.Close


modified 30-Sep-14 22:30pm.

AnswerRe: Writing XML from Excel Using VBA Pin
Richard Deeming1-Oct-14 2:45
mveRichard Deeming1-Oct-14 2:45 
Questiondelimiter or tokenizer in xslt Pin
DanielSatheesh27-Aug-14 2:22
MemberDanielSatheesh27-Aug-14 2:22 
AnswerRe: delimiter or tokenizer in xslt Pin
George Jonsson14-Sep-14 0:55
professionalGeorge Jonsson14-Sep-14 0:55 
QuestionMultiple namespaces in xslt Pin
MaryJames7-May-14 23:00
MemberMaryJames7-May-14 23:00 
AnswerRe: Multiple namespaces in xslt Pin
Richard MacCutchan7-May-14 23:24
mveRichard MacCutchan7-May-14 23:24 
GeneralRe: Multiple namespaces in xslt Pin
MaryJames8-May-14 4:16
MemberMaryJames8-May-14 4:16 
GeneralRe: Multiple namespaces in xslt Pin
Richard MacCutchan8-May-14 4:19
mveRichard MacCutchan8-May-14 4:19 
QuestionUse XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Christian Treffler2-Apr-14 9:15
MemberChristian Treffler2-Apr-14 9:15 
AnswerRe: Use XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Bernhard Hiller2-Apr-14 22:24
MemberBernhard Hiller2-Apr-14 22:24 
GeneralRe: Use XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Christian Treffler3-Apr-14 5:03
MemberChristian Treffler3-Apr-14 5:03 
QuestionXpath selecting nodes based on multiple attributes Pin
joost.versteegen4-Dec-13 5:28
Memberjoost.versteegen4-Dec-13 5:28 
AnswerRe: Xpath selecting nodes based on multiple attributes Pin
PIEBALDconsult4-Dec-13 5:46
professionalPIEBALDconsult4-Dec-13 5:46 
GeneralRe: Xpath selecting nodes based on multiple attributes Pin
joost.versteegen4-Dec-13 21:50
Memberjoost.versteegen4-Dec-13 21:50 
AnswerRe: Xpath selecting nodes based on multiple attributes Pin
Richard Deeming4-Dec-13 5:57
mveRichard Deeming4-Dec-13 5:57 
QuestionXPath following-sibling Pin
savbace21-Oct-13 0:20
Membersavbace21-Oct-13 0:20 
QuestionXML validation. Pin
Septimus Hedgehog18-Aug-13 23:02
MemberSeptimus Hedgehog18-Aug-13 23:02 
AnswerRe: XML validation. Pin
joost.versteegen5-Dec-13 23:00
Memberjoost.versteegen5-Dec-13 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.