Click here to Skip to main content
15,886,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have to get an xml on page load and store in variable ...how ?
Posted

1 solution

Why do you need to store entire XML in a variable? Instead you can create a function to read XML File. If you still want to do so, use:
C#
XDocument doc = XDocument.Load("XMLFile1.xml" );


[Update]
C#
//Calling a function
XDocument doc = MyFunction();

//Function Here
private XDocument MyFunction()
{
    return  XDocument.Load("XMLFile1.xml" );
}

--Amy
 
Share this answer
 
v2
Comments
Naveen Singh 25-Aug-14 5:20am    
how could i do so by creating function ?
_Amy 25-Aug-14 5:26am    
See my updated answer. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900