Click here to Skip to main content
15,913,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: Check Application Pin
Stefan Troschuetz1-Feb-07 8:22
Stefan Troschuetz1-Feb-07 8:22 
AnswerRe: Check Application Pin
Luc Pattyn1-Feb-07 8:23
sitebuilderLuc Pattyn1-Feb-07 8:23 
QuestionGraphic library Pin
Michael O.1-Feb-07 7:22
Michael O.1-Feb-07 7:22 
AnswerRe: Graphic library Pin
Luc Pattyn1-Feb-07 8:26
sitebuilderLuc Pattyn1-Feb-07 8:26 
AnswerRe: Graphic library Pin
Christian Graus1-Feb-07 9:23
protectorChristian Graus1-Feb-07 9:23 
AnswerRe: Graphic library Pin
Michael O.1-Feb-07 12:26
Michael O.1-Feb-07 12:26 
GeneralRe: Graphic library Pin
Christian Graus1-Feb-07 14:39
protectorChristian Graus1-Feb-07 14:39 
Question[C# .NET 2.0 VS 2005] deserializer problem : attributes are null ? [modified] Pin
Fabrice Deshayes aka Xtream1-Feb-07 6:52
Fabrice Deshayes aka Xtream1-Feb-07 6:52 
Hi,

I would like to deserialized in class and XML document which can be found on this URL : http://ws.audioscrobbler.com/1.0/artist/Metallica/similar.xml

Here is my two class to deserialized this XML but i've got a problem. After deserialization, i've got in attributes SimilarArtists.artists a list of 100 artists (which is good) but all artist's attributes are null (for string) or zero (for int).

There's something wrong but i don't see.. Frown | :-(

maybe someone can see something that i can't ?

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Net;
using System.IO;

namespace Xtream_ToolBox.Sensors {
    [XmlRoot("similarartists")]
    public class SimilarArtists {
        [XmlIgnore]
        public List<Artist> artists = new List<Artist>();

        // default constructor (required for serialisation)
        public SimilarArtists() {
        }

        public static SimilarArtists loadFromUrl(String url) {
            SimilarArtists similarArtists = null;
            Uri uri = new Uri(url);
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SimilarArtists));

            try {
                WebResponse webResponse = HttpWebRequest.CreateDefault(uri).GetResponse();
                Stream stream = webResponse.GetResponseStream();
                similarArtists = (SimilarArtists)xmlSerializer.Deserialize(stream);
                stream.Close();
            } catch (Exception e) {
                Console.WriteLine(e.Message);
            }

            return similarArtists;
        }


        // getter for events list (convert to array for xml serialization)
        [XmlElement("artist")]
        public Artist[] artistArray {
            get {
                Artist[] artistArray = new Artist[artists.Count];
                artists.CopyTo(artistArray);
                return artistArray;
            }
            set {
                if (value == null) return;
                Artist[] artistArray = (Artist[])value;
                artists.Clear();
                foreach (Artist artist in artistArray) {
                    artists.Add(artist);
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace Xtream_ToolBox.Sensors {
    public class Artist {
        [XmlAttribute("name")]
        public String name;
        [XmlAttribute("match")]
        public int match;
        [XmlAttribute("url")]
        public String url;
        [XmlAttribute("image_small")]
        public String imageSmall;

        // default constructor (required for serialisation)
        public Artist() {
        }
    }
}




-- modified at 6:53 Saturday 3rd February, 2007
nobody has an idea ?
QuestionSeemingly seperate strings point to same object Pin
crunchi1-Feb-07 6:25
crunchi1-Feb-07 6:25 
AnswerRe: Seemingly seperate strings point to same object Pin
Marc Clifton1-Feb-07 6:52
mvaMarc Clifton1-Feb-07 6:52 
AnswerRe: Seemingly seperate strings point to same object Pin
PIEBALDconsult1-Feb-07 7:09
mvePIEBALDconsult1-Feb-07 7:09 
GeneralRe: Seemingly seperate strings point to same object Pin
crunchi1-Feb-07 12:50
crunchi1-Feb-07 12:50 
GeneralRe: Seemingly seperate strings point to same object Pin
Russell Jones1-Feb-07 22:01
Russell Jones1-Feb-07 22:01 
AnswerRe: Seemingly seperate strings point to same object Pin
Judah Gabriel Himango1-Feb-07 7:56
sponsorJudah Gabriel Himango1-Feb-07 7:56 
GeneralRe: Seemingly seperate strings point to same object Pin
crunchi1-Feb-07 12:52
crunchi1-Feb-07 12:52 
GeneralRe: Seemingly seperate strings point to same object Pin
Judah Gabriel Himango1-Feb-07 13:23
sponsorJudah Gabriel Himango1-Feb-07 13:23 
QuestionDataTable.Select() [modified] Pin
lost in transition 1-Feb-07 6:03
lost in transition 1-Feb-07 6:03 
QuestionHow do I select the "Directory" Pin
Eyungwah1-Feb-07 6:01
Eyungwah1-Feb-07 6:01 
QuestionHow do I select the "Directory" Pin
Eyungwah1-Feb-07 6:04
Eyungwah1-Feb-07 6:04 
AnswerRe: How do I select the "Directory" Pin
Luc Pattyn1-Feb-07 6:31
sitebuilderLuc Pattyn1-Feb-07 6:31 
QuestionC# equilavent functionality to a C++ Vector Pin
rishid71-Feb-07 5:15
rishid71-Feb-07 5:15 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Mircea Puiu1-Feb-07 5:30
Mircea Puiu1-Feb-07 5:30 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Luc Pattyn1-Feb-07 6:37
sitebuilderLuc Pattyn1-Feb-07 6:37 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Marc Clifton1-Feb-07 7:13
mvaMarc Clifton1-Feb-07 7:13 
Questionhow to put the gradient effect on the BindingNavigator object's bacground in Windows Forms Pin
Rocky#1-Feb-07 5:11
Rocky#1-Feb-07 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.