所有示例都显示如何从本地文件读取xml。但是,如何从URL或流中读取xml并进一步处理呢?撒克逊.Net从流中读取xml
例子:http://www.oreillynet.com/xml/blog/2006/03/hello_saxon_on_net_an_aspnet_i.html
在此先感谢
所有示例都显示如何从本地文件读取xml。但是,如何从URL或流中读取xml并进一步处理呢?撒克逊.Net从流中读取xml
例子:http://www.oreillynet.com/xml/blog/2006/03/hello_saxon_on_net_an_aspnet_i.html
在此先感谢
在Sourceforge和www.saxonica.com上提供的撒克逊资源下载中查找XsltExamples.cs。第一个例子似乎正在做你所要求的。
public static void ExampleSimple1(String sourceUri, String xsltUri) {
// Create a Processor instance.
Processor processor = new Processor();
// Load the source document
XdmNode input = processor.NewDocumentBuilder().Build(new Uri(sourceUri));
// Create a transformer for the stylesheet.
XsltTransformer transformer = processor.NewXsltCompiler().Compile(new Uri(xsltUri)).Load();
// Set the root node of the source document to be the initial context node
transformer.InitialContextNode = input;
// Create a serializer
Serializer serializer = new Serializer();
serializer.SetOutputWriter(Console.Out);
// Transform the source XML to System.out.
transformer.Run(serializer);
}
是否使用XmlDocument对象用于读取XML?如果是这样,您需要XMLDocument.Load()方法,该方法可以将文件路径或URL,TextReader或Stream作为输入。
同样,XDocument.Load()(msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.load(v=vs.110).aspx)也有一组类似的重载。
完美!我会给你买一瓶啤酒,非常感谢你。 – cysus