Marshalling DIDL-Lite with Go's xml package

jerryb

New Member
Here's a sample DIDL-Lite XML document from the UPnP AV ContentDirectory v2 Service Template:\[code\]<?xml version="1.0" encoding="UTF-8"?><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ http://www.upnp.org/schemas/av/didl-lite-v2-20060531.xsd urn:schemas-upnp-org:metadata-1-0/upnp/ http://www.upnp.org/schemas/av/upnp-v2-20061231.xsd"> <item id="18" parentID="13" restricted="0"> ... </item></DIDL-Lite>\[/code\]How would one go about marshalling to this with Go's xml package? More specifically:[*]How are namespace prefixes defined, such as \[code\]xmlns:dc\[/code\] and \[code\]xmlns:upnp\[/code\]?[*]How are multiple name spaces configured on an element?[*]How is the namespace set for attributes, such as the \[code\]xsi\[/code\] prefix on the \[code\]schemaLocation\[/code\] attribute?As a base, I have something like this:\[code\]type DIDLLite struct { XMLName xml.Name `xml:"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ DIDL-Lite"` // ??? namespace prefixes dc, upnp, xsi Objects []Object}\[/code\]I've also found this possibly related bug.
 
Back
Top