Hiya,
excuse the highly noobistic nature of my question... I'm not a programmer, but I can write some basic python, but lxml is all new to me.
In essence, I need to build an xml file to a very specific format. Unfortunately, that target format utilizes multiple keys (? semantics...) per line, without a line break, like:
<key>Track ID</key><integer>971</integer>
<key>Name</key><string>Citadel Station</string>
…
[View More]<key>Artist</key><string>Disrupt</string>
I found the syntax to nest multiple keys, and to white-space them properly for .xml file usage, but I have not found a way to have multiple consecutive keys per line (without a line-break / whiste space inbetween them).
What I have (python bits to reproduce them below):
----------------------------------------
<key>some value3</key>
<string>some value5</string>
----------------------------------------
What I try to achieve:
----------------------------------------
<key>some value3</key><string>some value5</string>
----------------------------------------
If anyone has any pointers, that would be grand.
Cheerio & all the best!
c.
-----------------------------------------------------
import lxml.etree
import lxml.builder
E = lxml.builder.ElementMaker()
#dict & key syntax
DICT = E.dict
KEY = E.key
TrackID = E.key
Name = E.key
Artist = E.key
INTGR = E.integer
STRNG = E.string
DTE = E.date
the_XML = DICT(
DICT(
KEY('2'),
DICT(
TrackID('some value1', INTGR('some value3')), #nested trees/keys
Name('some value2'), STRNG('some value4'), #standard behaviour
Artist('some value3'), STRNG('some value5'), # how to print this in a single line: <key>some value3</key><string>some value5</string>
),
KEY('4'),
)
)
print lxml.etree.tostring(the_XML, pretty_print=True)
[View Less]