Hi all,
I have a very simple XSPF file:
<? XML version = "1.0"?>
<Playlist version = "1" xmlns = "http://xspf.org/ns/0/">
<Title> Easter mix </title>
<Info> This is our selection for the Easter period. </INFO>
<Tracklist>
<Track>
<Info> some info </INFO>
<Creator> some creator </creator>
<Title> A title </title>
<Location> location1.mp3 </location>
<Image> some.jpg </image>
</Track>
<Track>
<Info> some info </INFO>
<Creator> some creator </creator>
<Title> A title </title>
<Location> location2.mp3 </location>
<Image> some.jpg </image>
</Track>
</Tracklist>
</Playlist>
I am trying to get the title and info elements at the top of the document using
Xmldoc. selectnodes ("/playlist/Title ")
Or
Xmldoc. selectsinglenode ("/playlist/Title ")
But it just doesn't find it. Anybody knows how shoshould I do it?
Many thanks
Not sure what language you are coding in but your problem is you have a namespace in your XML and you are not querying the XML using it. here is some sample code that shows you how to add a namespace to solve the problem
Xmldocument xmldoc =NewXmldocument (); xmldoc. Load ("Playlist. xml"); Xmlnamespacemanager manager =NewXmlnamespacemanager (xmldoc. nametable); manager. addnamespace ("XSPF","Http:// Xspf.org/ns/0 /");String title = xmldoc. selectsinglenode ("// XSPF: Title ", Manager). innertext