Hello all
I have written the following LO Basic code to write XML via SAX to a file:
Sub WriteXMLwithSAX()
Dim sFil As String
sFil = "/tmp/output.xml" ' Change this for your needs
Dim oSFA As Object
oSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
If oSFA.exists(sFil) Then oSFA.kill(sFil)
Dim oStm As Object
oStm = oSFA.openFileWrite (sFil)
Dim oSax As Object
oSax = CreateUnoService ("com.sun.star.xml.sax.Writer")
oSax.setOutputStream (oStm)
oSax.startDocument()
oSax.startElement("TopElement", Null) ' Instead of Null I'd like to
' use an XAttributeList element
oSax.startElement("ChildElement", Null)
oSax.characters("ChildValue")
oSax.endElement("ChildElement")
oSax.endElement("TopElement")
oSax.endDocument()
oStm.closeOutput()
End Sub
This produces a very pretty result â/tmp/output.xmlâ as expected:
<?xml version="1.0" encoding="UTF-8"?>
<TopElement><ChildElement>ChildValue</ChildElement></TopElement>
However, Iâd like to add attributes to the elements âTopElementâ and âChildElementâ to obtain e.g. a result like this:
<?xml version="1.0" encoding="UTF-8"?>
<TopElement A="Val1"><ChildElement B="Val2">ChildValue</ChildElement></TopElement>
If I read the LO SDK API correctly, I therefore should use a âXAttributeListâ instead of the âNullâ that I use above for calls of âstartElement()â. âXAttributeListâ only has âgetâŚâ functions but no âsetâŚâ functions and that is why I donât have any idea how to create a valid âXAttributeListâ for the use with âstartElement()â. Can someone give me a hint how to create a âXAttributeListâ?
Thank you very much.