开发者

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 e.g.

<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:

<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.

This would result in the main xml file being downloaded and completed and then the two xml files being seperately downloaded too. Is it possible to read the main xml and the "sub xml" files all in one go?

开发者_高级运维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.


No, unless the fetching on the server side is done by ASP.NET or anything 'active'. 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.

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.


If I understood you correctly, you want to establish a relation between a generic item.xml and lots of subitem.xml files. (right ?)

Then you should rather use a relational database instead of trying to connect xml files. Or put all together in one file, as long as it's not getting to big. Everything else is waste of your time. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜