简体   繁体   English

是否可以“一次性完成”读取链接到另一个XML文件中的XML文件?

[英]Is it possible read XML files that are linked to within another XML file “all in one go”?

I have an XML file stored on a server which contains elements, of which some are refererences to other xml files eg 我有一个存储在包含元素的服务器上的XML文件,其中一些是对其他xml文件的引用,例如

<xml>
<item>value</item>
<data>http://www.example.org/item1.xml</data>
<data>http://www.example.org/item2.xml</data>
</xml>

Where item1 and item2 are like this for example: 例如,item1和item2如下所示:

<item>
  <id>1</id>
  <name>Item One</name>
</item>

I want to be able to read the main XML file (which of course I can do) this is done with an Asyncronous web request to download the XML - would it be possible to read the XML files referenced within the XML file in the same "request" rather than spin up, in this case two more seperate webclient requests to download these, as because these would be asyncronous too and therefore this data would not be available until those requests have completed - for binding to a UI in XAML for instance. 我希望能够读取主XML文件(我当然可以做到),这是通过异步Web请求下载XML来完成的-是否有可能读取XML文件中同一“请求”而不是启动,在这种情况下,还有两个单独的Web客户端请求下载这些请求,因为这些请求也将是异步的,因此在这些请求完成之前该数据将不可用-例如绑定到XAML中的UI。

This would result in the main xml file being downloaded and completed and then the two xml files being seperately downloaded too. 这将导致主要xml文件被下载并完成,然后两个XML文件也被单独下载。 Is it possible to read the main xml and the "sub xml" files all in one go? 是否可以一次读取主xml文件和“ sub xml”文件?

I can only use Async webrequests as this is a platform limitation of Silverlight and I cannot change the data as it is distibuted between many XML files to save server storage and is in a provided format, can the main and sub XML files be downloaded and parsed in one request, using LINQ / XElement / Silverlight supported features - I cannot use XPath as this would not be supported. 我只能使用Async webrequests,因为这是Silverlight的平台限制,并且我无法更改数据,因为它在许多XML文件之间分发以保存服务器存储并采用了提供的格式,可以下载和解析主XML文件和子XML文件在一个请求中,使用LINQ / XElement / Silverlight支持的功能-我无法使用XPath,因为它将不被支持。

No, unless the fetching on the server side is done by ASP.NET or anything 'active'. 不可以,除非在服务器端通过ASP.NET或任何“活动的”方式进行获取。 Differently put, if you're fetching the XML as a static file using HTTP, then of course nothing will work except what you already know - parse the XML on reception, then fire off two more requests. 换句话说,如果您要使用HTTP将XML提取为静态文件,那么除了您已经知道的内容外,其他任何事情都不会起作用-在接收时解析XML,然后触发另外两个请求。

If you're serving your Silverlight app from an ASP.NET capable server, you can always build a small aspx (even better ashx) which will fetch all of the XML files, merge them and respond with only one XML. 如果要从具有ASP.NET的服务器上提供Silverlight应用程序,则始终可以构建一个小的aspx(甚至更好的ashx),该aspx可以提取所有XML文件,合并它们并仅使用一个XML进行响应。

If I understood you correctly, you want to establish a relation between a generic item.xml and lots of subitem.xml files. 如果我对您的理解正确,那么您想在通用item.xml和许多subitem.xml文件之间建立relation (right ?) (对 ?)

Then you should rather use a relational database instead of trying to connect xml files. 然后,您应该使用关系数据库,而不要尝试连接xml文件。 Or put all together in one file, as long as it's not getting to big. 或者将所有文件放在一起,只要文件不大即可。 Everything else is waste of your time. 其他一切都浪费您的时间。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM