Click here to Skip to main content
15,890,527 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to store arraylist in string??????????? Pin
Parwej Ahamad22-Oct-10 6:00
professionalParwej Ahamad22-Oct-10 6:00 
QuestionAdding DataBase to Project Pin
future383921-Oct-10 15:33
future383921-Oct-10 15:33 
AnswerRe: Adding DataBase to Project Pin
Not Active22-Oct-10 3:20
mentorNot Active22-Oct-10 3:20 
AnswerRe: Adding DataBase to Project Pin
fjdiewornncalwe22-Oct-10 3:31
professionalfjdiewornncalwe22-Oct-10 3:31 
GeneralRe: Adding DataBase to Project Pin
future383922-Oct-10 13:00
future383922-Oct-10 13:00 
GeneralRe: Adding DataBase to Project Pin
fjdiewornncalwe22-Oct-10 14:20
professionalfjdiewornncalwe22-Oct-10 14:20 
GeneralRe: Adding DataBase to Project Pin
future383922-Oct-10 14:59
future383922-Oct-10 14:59 
QuestionXML deserialization Pin
indian14321-Oct-10 10:23
indian14321-Oct-10 10:23 
Hi All,

I have XML string as below. I am trying to deserialize this xml string in to a Request Object or NewHire Object. I have designed the Request class as it holds
the instance of NewHire class as a public property. I did in two ways

1. First time when I tried for the Request type it was giving exception like error in identifying property NewHire.

2. Then I deleted the Request element from the xml and kept from NewHire to /NewHire part only and then tried to deserialize the object for the NewHire type.
Then its not giving the exception but all the values in the NewHire instance it is giving null. Its not reading the values.

XML File :
----------
string strXML = "" + "<Request>" + "<NewHire>"
+ "<CompanyCandidateCode>CandCode</CompanyCandidateCode>"+ "<SSN>SSS</SSN>"
+ "<LastName>6456</LastName>"+ "<FirstName>3434</FirstName>"
+ "<MiddleName>676</MiddleName>"+ "<EthnicGroup>546456</EthnicGroup>"
+ "<Address>tuituiu</Address>"+ "<City>dfgfd</City>"
+ "<State>ghjgjg</State>"+ "<Zip>345345</Zip>"
+ "<HomePhone>bvnbvn</HomePhone>"+ "<OtherPhone>234234</OtherPhone>"+ "</NewHire>"+ "</Request>";

Deserialize Code:
----------------
            try
            {
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Request));
            System.IO.TextReader reader =
                new System.IO.StreamReader(new MemoryStream(ASCIIEncoding.Default.GetBytes(strXML))); 
           
            Request ObjItems;

            ObjItems = (Request)serializer.Deserialize(reader);
                reader.Close();

                string str = Convert.ToString(ObjItems.NewHire.Address);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


I want to read this in to my Request or NewHire objects any of the above two methods ok. I prefer for the first one to fill the Request ojbect but if it can fill only NewHire
object and cant fill an object containing another object, I will adjust with NewHire only.

Can anybody please help me in this regard as I have to deserialize it in anyway.
Thanks & Regards,

Md. Abdul Aleem
NIIT technologies

AnswerRe: XML deserialization Pin
T M Gray21-Oct-10 11:06
T M Gray21-Oct-10 11:06 
GeneralRe: XML deserialization Pin
indian14321-Oct-10 12:26
indian14321-Oct-10 12:26 
QuestionRSS Feed Aggregation Pin
devenneym21-Oct-10 9:59
devenneym21-Oct-10 9:59 
QuestionSystem.FormatException: String was not recognized as a valid DateTime Pin
Asif Rehman21-Oct-10 1:18
Asif Rehman21-Oct-10 1:18 
AnswerRe: System.FormatException: String was not recognized as a valid DateTime Pin
Pete O'Hanlon21-Oct-10 1:25
mvePete O'Hanlon21-Oct-10 1:25 
GeneralRe: System.FormatException: String was not recognized as a valid DateTime Pin
Asif Rehman21-Oct-10 1:37
Asif Rehman21-Oct-10 1:37 
GeneralRe: System.FormatException: String was not recognized as a valid DateTime Pin
Pete O'Hanlon21-Oct-10 1:55
mvePete O'Hanlon21-Oct-10 1:55 
AnswerThanks It works. Pin
Asif Rehman21-Oct-10 2:15
Asif Rehman21-Oct-10 2:15 
GeneralRe: Thanks It works. Pin
Pete O'Hanlon21-Oct-10 2:57
mvePete O'Hanlon21-Oct-10 2:57 
QuestionAjax in aspx page Pin
Morgs Morgan20-Oct-10 22:54
Morgs Morgan20-Oct-10 22:54 
AnswerRe: Ajax in aspx page Pin
Blue_Boy20-Oct-10 23:30
Blue_Boy20-Oct-10 23:30 
Questionpopup window open automatically when a row inserted to the table Pin
Ahamed Azeem20-Oct-10 22:33
Ahamed Azeem20-Oct-10 22:33 
AnswerRe: popup window open automatically when a row inserted to the table Pin
Morgs Morgan20-Oct-10 23:06
Morgs Morgan20-Oct-10 23:06 
AnswerRe: popup window open automatically when a row inserted to the table Pin
Prerak Patel20-Oct-10 23:11
professionalPrerak Patel20-Oct-10 23:11 
QuestionDataset VS SQL Server Database Pin
future383920-Oct-10 16:09
future383920-Oct-10 16:09 
AnswerRe: Dataset VS SQL Server Database Pin
Brij20-Oct-10 17:56
mentorBrij20-Oct-10 17:56 
QuestionAdvantages of .ashx pages. Pin
anoop_m8320-Oct-10 13:23
anoop_m8320-Oct-10 13:23 

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.