Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Aug 14, 2013

What is XPath and Its basic functions

Views:


XPATH is  XML path language. As from abbreviation, it is an XML language which is use for the query to selecting XML node from XML document.

XPath  also used for compute values  (e.g., strings, numbers, or Boolean values) and converting values from one type to other from the content of XML documents.

XPath was defined by  World Wide Web Consortium (W3C).
This is Complete Tutorial in which I will  explain everything Which is closely related to  XPATH.

Feb 16, 2013

Remove all empty tags from XML in Java , C#

Views:

Remove All Empty Tags From  XML in Java , C#
To Day I will show you how to remove all empty tags from XML File or a string Variable that contains  XML data, in both languages C# and Java.

In My Previous tutorial,  I show how to Remove Empty Lines from  a string or from XML Data, After removing empty tags from XML there will be Empty Line in XML data besides these tags. So you must go through this tutorial as well.

In this tutorial Again I will Use Regex Expression to identify empty tags from XML string or File and  replace these empty lines with my respected tags or string  or left them empty.

Feb 15, 2013

Remove Empty Lines from String or XML

Views:

To day I will show you How to Remove Empty Lines from string variable or  string Variable containing XML Data .

This Code will Work on Both C# and Java Language.

In Code I use Reg-ex Expression  To Detect or Find empty lines from String and Replace any other Character , join with Previous line or Else ..

Aug 9, 2012

Read Or Parse XML File From Web Server in Android

Views:

Read Or Parse XML File From Web Server in Android
To Day I will show you How to read or Parse Xml File Hosted on Web Server or Hosting Server using Android .
In this tutorial we Will Talk about How to Parse Xml file and How to Bind With List View in Android.

In This Tutorials We will be Using .
1) HTTP Request to get XML File from Web Server or Hosting Server.
2) Read Or access XML Data .

Jul 29, 2012

Access XML File Hosted on Php Server In Windows Phone 7

Views:

Access XML File Hosted on Php Server In Windows Phone 7
To Day I show you how to Access XML File Hosted on Php web Server Server or any other Server  In Windows Phone 7.

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).
Access XML File Hosted on Php Server In Windows Phone 7

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.
Access XML File Hosted on Php Server In Windows Phone 7


Now Select File Manager  (Clcik File Manager ) It ask for Password Enter the Password Which you Write in Signup time.
Access XML File Hosted on Php Server In Windows Phone 7

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

<?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>
Now you Xml File is Live and Sucesfully Hosted.
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 .
Access XML File Hosted on Php Server In Windows Phone 7
Access XML File Hosted on Php Server In Windows Phone 7
Access XML File Hosted on Php Server In Windows Phone 7

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 Person
    {
        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; }
        }
    }
And Here The Method Which Loads XML Data From PHP server.
public void loadXmlFromPHpServer(string xmlUrl, ListBox listbox)
   {
   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);
BENEFITS
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
Access XML File Hosted on Php Server In Windows Phone 7


Become a Fan

visual studio learn