所有示例都顯示如何從本地文件讀取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