Click here to Skip to main content
15,881,882 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XSL: how to properly reference to xml field? Pin
Maciej Los17-Nov-14 4:25
mveMaciej Los17-Nov-14 4:25 
QuestionHow to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire30-Oct-14 3:53
professionalJohn Whitmire30-Oct-14 3:53 
AnswerRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
Gerry Schmitz30-Oct-14 21:21
mveGerry Schmitz30-Oct-14 21:21 
GeneralRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire3-Nov-14 3:04
professionalJohn Whitmire3-Nov-14 3:04 
SuggestionRe: How to get behavior similar to the obsoleted XmlValidatingReader Pin
John Whitmire6-Nov-14 2:47
professionalJohn Whitmire6-Nov-14 2:47 
QuestionVB.NET creat new XML Pin
Dereak12-Oct-14 17:43
Dereak12-Oct-14 17:43 
AnswerRe: VB.NET creat new XML Pin
User 41802545-Aug-15 2:28
User 41802545-Aug-15 2:28 
QuestionWriting XML from Excel Using VBA Pin
gedkins@deltagl.com30-Sep-14 14:15
gedkins@deltagl.com30-Sep-14 14: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
<?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.

VB
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 1:45
mveRichard Deeming1-Oct-14 1:45 
Questiondelimiter or tokenizer in xslt Pin
DanielSatheesh27-Aug-14 1:22
DanielSatheesh27-Aug-14 1:22 
AnswerRe: delimiter or tokenizer in xslt Pin
George Jonsson13-Sep-14 23:55
professionalGeorge Jonsson13-Sep-14 23:55 
QuestionMultiple namespaces in xslt Pin
MaryJames7-May-14 22:00
MaryJames7-May-14 22:00 
AnswerRe: Multiple namespaces in xslt Pin
Richard MacCutchan7-May-14 22:24
mveRichard MacCutchan7-May-14 22:24 
GeneralRe: Multiple namespaces in xslt Pin
MaryJames8-May-14 3:16
MaryJames8-May-14 3:16 
GeneralRe: Multiple namespaces in xslt Pin
Richard MacCutchan8-May-14 3:19
mveRichard MacCutchan8-May-14 3:19 
QuestionUse XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Christian Treffler2-Apr-14 8:15
Christian Treffler2-Apr-14 8:15 
AnswerRe: Use XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Bernhard Hiller2-Apr-14 21:24
Bernhard Hiller2-Apr-14 21:24 
GeneralRe: Use XmlAttributeOverrides, but get an InvalidOperationException nevertheless Pin
Christian Treffler3-Apr-14 4:03
Christian Treffler3-Apr-14 4:03 
QuestionXpath selecting nodes based on multiple attributes Pin
joost.versteegen4-Dec-13 4:28
joost.versteegen4-Dec-13 4:28 
AnswerRe: Xpath selecting nodes based on multiple attributes Pin
PIEBALDconsult4-Dec-13 4:46
mvePIEBALDconsult4-Dec-13 4:46 
GeneralRe: Xpath selecting nodes based on multiple attributes Pin
joost.versteegen4-Dec-13 20:50
joost.versteegen4-Dec-13 20:50 
AnswerRe: Xpath selecting nodes based on multiple attributes Pin
Richard Deeming4-Dec-13 4:57
mveRichard Deeming4-Dec-13 4:57 
QuestionXPath following-sibling Pin
savbace20-Oct-13 23:20
savbace20-Oct-13 23:20 
QuestionXML validation. Pin
Septimus Hedgehog18-Aug-13 22:02
Septimus Hedgehog18-Aug-13 22:02 
AnswerRe: XML validation. Pin
joost.versteegen5-Dec-13 22:00
joost.versteegen5-Dec-13 22: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.