The method of calling XML in non-xap in clientbin in Silverlight

Source: Internet
Author: User
Tags silverlight

Some time ago, I tried to write a Silverlight application, where XML needs to be read as a data file. However, since the data in XML needs to be changed externally at any time, it is inconvenient to put it in xap, so as not to violate the trend of a pseudo-OO language "Ox, run everywhere", and put it directly under clientbin, so various attempts were made.

First of all, naturally, after reading msdn, we chose xmlreader directly. create (string URI) to create reader, unfortunately... cup, where the URI directly points to the xap. (M $, you dare to give xmlreader. create (URI) overload)

Speaking of Uri, if the relative address in Sl is "image/1.jpg", first check whether 1.jpg is available under clientbin/image. then find it under xap. If "~ Image/1.jpg", then you can directly find whether there is an xap...

Then. various search strategy, during which various types of hydrology were found (various domestic forums are really a mix of fish and dragons, although Crouching Tiger, hiding dragon, but there is still a god of ordinary guys-_-, PS: I am a commodity ), I said you can run the code before writing the xmldocument, or do you have a good idea about the following msdn? It clearly says that xmldocument is unavailable ....

Well, Silverlight is not a bit slimming on WPF. Many functions are castrated. Originally, XML support is very powerful, and there are only a few common vulnerabilities. it has been a long time since we wrote the parsed class t_t.

Is the SL sauce really nice? Is it true that only one hand holds the right hand, or is poor r a scarce resource? M $ cannot be so evil...

The question is... the water has been going on for a long time...

Xmlparse:

From http://forums.silverlight.net/forums/t/99312.aspx

Public class xmlparser
{
Public Delegate void eventhandler (Object sender, xmlparsereventargs E );
Public event eventhandler completed;

Public void loadxmlfile (string xmluri)
{
WebClient xmlclient = new WebClient ();
Xmlclient. downloadstringcompleted + = new downloadstringcompletedeventhandler (xmlfileloaded );
Xmlclient. downloadstringasync (New uri (xmluri, urikind. relativeorabsolute ));
}

Void xmlfileloaded (Object sender, downloadstringcompletedeventargs E)
{
If (E. Error = NULL)
{
String xmldata = E. result;

If (completed! = NULL)
{
Completed (this, new xmlparsereventargs (xmldata ));
}
}
}
}

Public class xmlparsereventargs: eventargs
{
Public String xmlstring {Get; set ;}

Public xmlparsereventargs (string xmlstring)
{
This. xmlstring = xmlstring;
}
}
Using WebClient + asynchronous transmission seems to be able to obtain data from other websites, which is a good method. although there are still ways to modify it, I will try again later. find the paradigm in the link...

====================================== People, which of the following is NOT a separation line? ============================================

[Reprinted from http://hi.baidu.com/avalontm/blog/item/bae82d3cbbe006cd9e3d6279.html]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.