As we Know that Use XML Files For Storing data and Retrieving Data Through LINQ (Language Integrated Query ).
We can Access an XML file From a Local (Isolated Storage ) and also From a web server Where XML file Is Hosted .
Note In XML File We Can Store XML file on PHP Server or on Free web Hosting Server.
Following Are the Steps Please Follow it.
First We Create an account on http://www.000webhost.com/ .It Provides Free PHP web Hosting .Note during Signup Choose SUB Domain which is free and (recommended).
Then Confirm Then Confirmation Email.
Now After Confirmation an Window open in which Select Domain Name From Drop Down and Press Go Buttton By this You Move To Control Penal of You Hosting Account.
Now Select File Manager (Clcik File Manager ) It ask for Password Enter the Password Which you Write in Signup time.
After this you are now in FTP manager Click Public Folder .Now you have to upload an XML file here i don't have any XML you can download Here Which I uploaded on Server .
my XML file Contains Following Data
for viewing URL of hosted XML file Click (Open Link) it open XML file in new Windows with Complete URL Please Save this URL It needs you in further Steps .
So open Visual Studio and Make a Simple Project on Windows phone 7 on C#.
you Need a list box with A data Template .List box has Following Code .
Now Add a Class in Project Name Person and Write Following Code
1) In this you can Update Data at Any time
2)It Free Data Server just Only For Data Not For Processing and Computation.
3)Data Is update By Admin .
4)We can Update aur Add more Data in XML File After Your Has been Published in Market Place and It Effects deploy on all user who Uses Your App.
DOWNLOAD COMPLETE SOURCE CODE
SCREEN SHORTS
Following Are the Steps Please Follow it.
First We Create an account on http://www.000webhost.com/ .It Provides Free PHP web Hosting .Note during Signup Choose SUB Domain which is free and (recommended).
Then Confirm Then Confirmation Email.
Now After Confirmation an Window open in which Select Domain Name From Drop Down and Press Go Buttton By this You Move To Control Penal of You Hosting Account.
Now Select File Manager (Clcik File Manager ) It ask for Password Enter the Password Which you Write in Signup time.
After this you are now in FTP manager Click Public Folder .Now you have to upload an XML file here i don't have any XML you can download Here Which I uploaded on Server .
my XML file Contains Following Data
Now you Xml File is Live and Sucesfully Hosted.<?xml version="1.0" ?><People><Person FirstName="Mohammad Sajjad Ashraf" LastName="AWAN" Age="27" /><Person FirstName="Mohammad Javed" LastName="Ashraf" Age="27" /><Person FirstName="Mohammad Zain Farooq" LastName="Ansari" Age="27" /><Person FirstName="Mohammad Irfan" LastName="Khan" Age="26" /><Person FirstName="Mohammad Jibran Ahmed" LastName="Khan" Age="28" /><Person FirstName="Kate" LastName="Smith" Age="27" /><Person FirstName="Tom" LastName="Brown" Age="30" /><Person FirstName="Tim" LastName="Stone" Age="36" /><Person FirstName="Ann" LastName="Peterson" Age="27" /></People>
for viewing URL of hosted XML file Click (Open Link) it open XML file in new Windows with Complete URL Please Save this URL It needs you in further Steps .
So open Visual Studio and Make a Simple Project on Windows phone 7 on C#.
you Need a list box with A data Template .List box has Following Code .
<ListBox x:Name="listBox2">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="20" >
<TextBlock Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Now Add a Class in Project Name Person and Write Following Code
public class PersonAnd Here The Method Which Loads XML Data From PHP server.
{
string firstname; string lastname;
int age;
public string FirstName
{
get { return firstname; }
set { firstname = value; }
}
public string LastName
{
get { return lastname; }
set { lastname = value; }
}
public int Age
{
get
{
return age;
}
set
{ age = value; }
}
}
public void loadXmlFromPHpServer(string xmlUrl, ListBox listbox)BENEFITS
{
try
{
WebClient client = new WebClient();
client.OpenReadCompleted += (sender, e) =>
{
if (e.Error != null)
return;
Stream str = e.Result;
XDocument xdoc = XDocument.Load(str);
var filteredData = from c in xdoc.Descendants("Person")
where c.Attribute("Age").Value == "27"
select new Person()
{
FirstName = c.Attribute("FirstName").Value,
LastName = c.Attribute("LastName").Value
};
listbox.ItemsSource = filteredData;
textBlock1.Text = "Total Items are Loaded =" + filteredData.Count<Person>();
};
client.OpenReadAsync(new Uri(xmlUrl, UriKind.Absolute));
}
catch (Exception)
{
}
}
You can Call This Method By Using Following Code on PageLoadEvent or Clcik event of Button Etc.
loadXmlFromPHpServer("http://muhammadsajjadashrafawan.comyr.com/MohammadSajjadAshrafAwan.xml", listBox2);
1) In this you can Update Data at Any time
2)It Free Data Server just Only For Data Not For Processing and Computation.
3)Data Is update By Admin .
4)We can Update aur Add more Data in XML File After Your Has been Published in Market Place and It Effects deploy on all user who Uses Your App.
DOWNLOAD COMPLETE SOURCE CODE
SCREEN SHORTS
well done man..i was looking for this one. You made my day :)
ReplyDeleteThe source code file is missing from 4shared, please fix it. Need the source codes!!!
ReplyDeleteDownload From Google Docs Its Working .. https://docs.google.com/file/d/0B0_Q3XaXeFp4ejEwWWl6RkJ2ckk/edit?usp=sharing
ReplyDeleteQuantum Binary Signals
ReplyDeleteProfessional trading signals delivered to your cell phone every day.
Follow our signals NOW and profit up to 270% daily.