Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:57:21+00:00 2026-06-04T22:57:21+00:00

Here’s a sample DIDL-Lite XML document from the UPnP AV ContentDirectory v2 Service Template

  • 0

Here’s a sample DIDL-Lite XML document from the UPnP AV ContentDirectory v2 Service Template:

<?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>

How would one go about marshalling to this with Go’s xml package? More specifically:

  1. How are namespace prefixes defined, such as xmlns:dc and xmlns:upnp?
  2. How are multiple name spaces configured on an element?
  3. How is the namespace set for attributes, such as the xsi prefix on the schemaLocation attribute?

As a base, I have something like this:

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
}

I’ve also found this possibly related bug.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:57:26+00:00Added an answer on June 4, 2026 at 10:57 pm

    The example you gave is marshalled. I assume you mean to ask, “how would one define Go data types that marshal with xml.Marshal into this?”

    package main
    
    import (
        "encoding/xml"
        "fmt"
    )
    
    type DIDLLite struct {
        XMLName xml.Name
        DC      string   `xml:"xmlns:dc,attr"`
        UPNP    string   `xml:"xmlns:upnp,attr"`
        XSI     string   `xml:"xmlns:xsi,attr"`
        XLOC    string   `xml:"xsi:schemaLocation,attr"`
        Objects []Object `xml:"item"`
    }
    
    type Object struct {
        ID         string `xml:"id,attr"`
        Parent     string `xml:"parentID,attr"`
        Restricted string `xml:"restricted,attr"`
    }
    
    func main() {
        d := DIDLLite{
            XMLName: xml.Name{
                Space: "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/",
                Local: "DIDL-Lite",
            },
            DC:   "http://purl.org/dc/elements/1.1/",
            UPNP: "urn:schemas-upnp-org:metadata-1-0/upnp/",
            XSI:  "http://www.w3.org/2001/XMLSchema-instance",
            XLOC: `
       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`,
            Objects: []Object{{ID: "18", Parent: "13", Restricted: "0"}},
        }
        b, err := xml.MarshalIndent(d, "", "    ")
        if err != nil {
            fmt.Println(err)
            return
        }
        fmt.Println(string(b))
    }
    

    Output:

    <DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" 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>
    

    which can be pretty printed to match your example above. xml.MarshallIndent is a little primitive yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my persistence.xml : <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd version=1.0>
Here's my Manifest: <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.mappp.mobile android:versionCode=1 android:versionName=1.0 > <supports-screens android:largeScreens=true
Here is a complete example. I want to forbid using A::set from objects casted
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
Here is my query: SELECT * FROM [GeoName] WHERE ((-26.3665122100029-Lat)*(-26.3665122100029-Lat))+((27.5978928658078-Long)*(27.5978928658078-Long)) < 0.005 ORDER BY
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here is my code sample, let me know if it can be further improved?
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here is my code, which takes two version identifiers in the form 1, 5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.