如何在页面上加载Xml并保存在变量中? [英] How Do I Get An An Xml On Page Load And Save In An Variable ?

查看:70
本文介绍了如何在页面上加载Xml并保存在变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在页面加载时获取xml并存储在变量中......如何?

i have to get an xml on page load and store in variable ...how ?

推荐答案

为什么需要将整个XML存储在变量中?相反,您可以创建一个读取XML文件的函数。如果您仍想这样做,请使用:

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:
XDocument doc = XDocument.Load("XMLFile1.xml" );





[更新]



[Update]

//Calling a function
XDocument doc = MyFunction();

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



- Amy


这篇关于如何在页面上加载Xml并保存在变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆