jnunemaker / crack

Really simple JSON and XML parsing, ripped from Merb and Rails.
MIT License
541 stars 93 forks source link

Xml parsing dont return attribute of tag #60

Closed arjunmenon closed 4 years ago

arjunmenon commented 6 years ago

Hey I have an XML like this

<DIDL-Lite
    xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"
    xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\"
    xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
    xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\"
    xmlns:sec=\"http://www.sec.co.kr/\"
    xmlns:pv=\"http://www.pv.com/pvns/\">
    <item id=\"0/all_tracks/47419\" parentID=\"0/all_tracks\" restricted=\"1\">
        <upnp:class>object.item.audioItem.musicTrack</upnp:class>
        <dc:title>The Local Train - Aaftaab Official Audio</dc:title>
        <dc:creator>&lt;unknown&gt;</dc:creator>
        <upnp:artist>&lt;unknown&gt;</upnp:artist>
        <upnp:albumArtURI>http://192.168.1.2:57745/external/audio/albums/113.jpg</upnp:albumArtURI>
        <upnp:albumArtURI dlna:profileID=\"JPEG_TN\">http://192.168.1.2:57745/external/audio/albums/113.jpg</upnp:albumArtURI>
        <upnp:album>Music</upnp:album>
        <ownerUdn>0ba501af-ad64-abe4-0000-000061ab1285</ownerUdn>
        <res protocolInfo=\"http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000\" size=\"9388725\" duration=\"0:03:54.000\">http://192.168.1.2:57745/external/audio/media/47419.mp3</res>
    </item>
</DIDL-Lite>

When parsing it returns

{"DIDL_Lite"=>
  {"item"=>
    {"upnp:class"=>"object.item.audioItem.musicTrack",
     "dc:title"=>"The Local Train - Aaftaab Official Audio",
     "dc:creator"=>"<unknown>",
     "upnp:artist"=>"<unknown>",
     "upnp:albumArtURI"=>
      ["http://192.168.1.2:57745/external/audio/albums/113.jpg",
       "http://192.168.1.2:57745/external/audio/albums/113.jpg"],
     "upnp:album"=>"Music",
     "ownerUdn"=>"0ba501af-ad64-abe4-0000-000061ab1285",
     "res"=>"http://192.168.1.2:57745/external/audio/media/47419.mp3",
     "id"=>"0/all_tracks/47419",
     "parentID"=>"0/all_tracks",
     "restricted"=>"1"},
   "xmlns"=>"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/",
   "xmlns:upnp"=>"urn:schemas-upnp-org:metadata-1-0/upnp/",
   "xmlns:dc"=>"http://purl.org/dc/elements/1.1/",
   "xmlns:dlna"=>"urn:schemas-dlna-org:metadata-1-0/",
   "xmlns:sec"=>"http://www.sec.co.kr/",
   "xmlns:pv"=>"http://www.pv.com/pvns/"}}

But if you notice the res tag, it is returning only the content which is a URL, but the tag has attributes like protocolinfo, duration, size, etc. I can't get them.

bf4 commented 4 years ago

Closing as stale.