XML and C# - Help pulling information from a certain element -


So I do not know this at all about the word, but here it goes. Now my application can pull information about XM user without problem. Sample XML:

  & lt; Status type = "array" & gt; & Lt; Status & gt; & Lt; ID & gt; ID1 & lt; / Id & gt; & Lt; Text & gt; The text that I read at 1 & lt; / Text & gt; & Lt; Users & gt; & Lt; Name & gt; User 1 & lt; / Name & gt; & Lt; SCREEN_NAME & gt; User1_Screen & lt; / SCREEN_NAME & gt; & Lt; Location & gt; Location_User1 & lt; / Location & gt; & Lt; Details & gt; User1_Description & lt; / Details & gt; & Lt; / User & gt; & Lt; / Status & gt; & Lt; Status & gt; & Lt; ID & gt; ID2 & lt; / Id & gt; & Lt; Text & gt; The text that I read at 2 & lt; / Text & gt; I want to stretch. & Lt; Users & gt; & Lt; Name & gt; User 2 & lt; / Name & gt; & Lt; SCREEN_NAME & gt; User2_Screen & lt; / SCREEN_NAME & gt; & Lt; Location & gt; Location_User2 & lt; / Location & gt; & Lt; Details & gt; User2_Description & lt; / Details & gt; & Lt; / User & gt; & Lt; / Status & gt;  

The screen_name tag is dragged into the listbox and here is the code that pulls the information in which it gives the user detail information:

  Private Zero ListBox 1 selected value (Object Sender, EventArgues E) {// Temp file var doc = Load XDocument.Load ("Temp.xml"); Var setting = doc.Descendants ("user") first (a = & gt; a.Element ("screen_name"). Value == listBox1.Text); // variable = setting for information from XML variable Element ("location"). Values; Var details = setting. Element ("Description"). Values; Var Screen_name = setting.Element ("name"). Values; // Info pulled from "temp.xml" location Text = "location:" + location; User name. Text = "name:" + screen_name; DescriptionBox.Text = "Description:" + Description; }  

And now I want to have a text tag, and I just have to find out this is a terrible time.

I run your code without problems. You should check:

  • Is your listBox1.Text price correct?
  • Are you trying to accept it Temp.xml in the correct path?
  • Are you sure that your Temp.xml is well-formed (this is & lt; / statuses & gt; missing); Try opening it in IE.

Edit : Try it:

  var text = setting.Parent.Element ("text") value.  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -