Connecting Tech Pros Worldwide Forums | Help | Site Map

"Reading data from Xml in smart phones "

Newbie
 
Join Date: Nov 2007
Posts: 16
#1: Nov 27 '07
hi guys,

My Xml File

<xml version="1.0">
<Name>
<Firstname> Infowave </Firstname>
<Lastname> Homes </Lastname>
</Name>
</xml>

Here am use Parent element '<name> and child elements <Firstname><Lastname> .......................

Im my smart pfone when i cick button i need these two
names in two text boxes....................
I already try "Server.Transfer" but this property is not support
Windows application. any one can give idea..................

Ganesh

markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#2: Nov 27 '07

re: "Reading data from Xml in smart phones "


Hi there,

you will need an xml reader to read in the xml values you want. Then use a nodelist to get the specific values you want and then save them.

i.e.
Expand|Select|Wrap|Line Numbers
  1.                     XmlDocument xmlDoc = new XmlDocument();
  2.                     xmlDetails.Load(xmlFilePath);
  3.                     XmlNodeList nodeList =               xmlDetails.GetElementsByTagName("Name");
  4.  
  5.                     string FirstName= "";
  6.                     string LastName= "";
  7.  
  8.                     foreach (XmlElement elem in nodeList)
  9.                     {
  10.                         foreach (XmlElement tempElem in elem.ChildNodes)
  11.                         {
  12.                             if (tempElem.Name == "FirstName")
  13.                             {
  14.                                 FirstName= tempElem.InnerText;
  15.                             }
  16.  
  17.                             if (tempElem.Name == "LastName")
  18.                             {
  19.                                 LastName= tempElem.InnerText;
  20.                             }
  21.                         }
  22.  
  23.                         break;
  24.                     }
  25.  
  26. this.textBox1.text = FirstName;
  27. this.textBox2.text = LastName;
  28.  
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,393
#3: Dec 6 '07

re: "Reading data from Xml in smart phones "


I deleted your other double post. Please do not do that again or there will be consequences.

-MODERATOR

Same for you Mark, but I deleted it (so your safe) :-P
Reply