using System.Text
using System.Xml
namespace ParsingXml
{
class Program
{
static void Main(string[] args)
{
XmlReader xmlReader = XmlReader.Create("c:/eurofxref-daily.xml")
while(xmlReader.Read())
{
if((xmlReader.NodeType == XmlNodeType.Element) &&(xmlReader.Name == "Cube"))
{
if(xmlReader.HasAttributes)
Console.WriteLine(xmlReader.GetAttribute("currency") + ": " + xmlReader.GetAttribute("rate"))
}
}
Console.ReadKey()
}
}
}
文件/获取外部数据/导入...在导入对话框最下面的文件类型选(*.xls)
然后是导入数据表向导,按步骤来就可以了,excel的格式最好能直接对上access,不然导进去表就乱了
按照access的使用方法既可读取调用
我理解你是想问:如何把xml文件保存到SqlServer数据库中?一个xml对应一个数据库表。通常就是读取xml中元素(节点)的值并作为insert
的参数,然后执行insert语句就是咯(当然你也可以把xml文件读到DataSet中,然后将DataSet数据保存到数据,这样不必使用Insert了)。至于你要打印那就是读数据库数据并整理的问题了。
但具体到你的问题,要看你xml文件的格式以及你要打印的格式才能给你代码。
补充问题的代码:
你可以使用Stream
s=StreamReader(fillpath,
System.Text.Encoding.GetEncoding("UTF-8")).BaseStream;直接把s作为文本存入你数据库中的列
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)