Close minutes 5.wml, UTF-8, BOM, signature and others

Source: Internet
Author: User

Now, it's quite difficult to do things easily (for example, the transformation of step1.cn and the creation of dituren.cn ), it is difficult to make any progress on things that are not easy to do. In addition, I have been very busy in the company recently, because I have to study things after I come back, but I still haven't made myself idle in any case, let's talk about the WAP Development recently studied.

Now start to study WAP do not know is a little early or a little late, this does not talk about it, now I finally launched a simple version of The http://wap.dituren.cn/WAP station, here are some tips:

First of all, let's talk about the UTF-8 Bom, also called signature, sometimes encountered such a problem: clearly a good format of XML files, encoding settings are also correct, but in some cases when opening, an error is always displayed, prompting that the XML root node cannot be found. I have been troubled by this problem for a long time during WAP Development (some simulators or mobile phones do not recognize files with BOM ), now, we finally understand that Bom is at fault. If you have encountered such a problem, we suggest you refer to the following address:

W3C description of BOM

C # how to generate a UTF-8 file without signature

If you use the window notepad to write XML, there is no place to set in the notepad, so it will write three bytes of BOM information. If you use editplus, in the tool-> parameter-> file, it is not difficult to find the setting. I set this project to "always remove the signature ".

Next, let's talk about the WAP development tool. Generally, mshortate is the strictest software, which is too strict (not supported by Google's WAP sites) and does not display specific errors, therefore, it is not suitable for development and debugging. I think openwave V7 simulator and Microsoft mobile explorer 3.0 are both good software. With debugging, there should be no major problems, in later adjustments, it is much easier to refer to mshortate.

Today is not enough time, not much to write, but here I attach the basics of using C # To operate XML to implement Google's mobile sitemapCodeBecause the new WAP sitemap format has changed, it is easy to mess up the namespace. If you are interested, please refer to the following code (see the Google mobile sitemap example for the generated file ):

 

C # mobile sitemap
1 Public   Class Placesitemap: system. Web. UI. Page
2 {
3 Xmldocument Doc = New Xmldocument ();
4 Xmlnode urlxmlnode;
5 String Nsurl = " Http://www.google.com/schemas/sitemap/0.9 " ;
6 String Mobileurl =   " Http://www.google.com/schemas/sitemap-mobile/1.0 " ;
7 Private   Void Page_load ( Object Sender, system. eventargs E)
8 {
9 Response. contenttype =   " Text/XML " ;
10 Response. charset =   " UTF-8 " ;
11 Doc. appendchild (Doc. createelement ( Null , " Urlset " , Nsurl ));
12 Doc. insertbefore (Doc. createxmldeclaration ( " 1.0 " , " UTF-8 " ), Doc. documentelement );
13 Xmlattribute ATTR = Doc. createattribute ( " Xmlns: Mobile " );
14 ATTR. Value = Mobileurl;
15 Doc. documentelement. Attributes. append (ATTR );
16 // Call this function again.
17 This . Createurl ( " Daily " , System. datetime. Now. tostring ( " S " ), " Http://wap.dituren.cn/place/cn/ " , " 1.0 " );
18 Doc. Save (response. outputstream );
19 }
20 Override   Protected   Void Oninit (eventargs E)
21 {
22Initializecomponent ();
23Base. Oninit (E );
24}
25 Private   Void Initializecomponent ()
26 {
27This. Load+ = NewSystem. eventhandler (This. Page_load );
28}
29 Private   Void Createurl ( String Changefreq, String Lastmod, String Loc, String Priority)
30 {
31 Urlxmlnode = Doc. createelement ( " URL " , Nsurl );
32 Urlxmlnode. appendchild (Doc. createelement ( " Changefreq " , Nsurl ));
33 Urlxmlnode [ " Changefreq " ]. Innertext = Changefreq;
34 Urlxmlnode. appendchild (Doc. createelement ( " Lastmod " , Nsurl ));
35 Urlxmlnode [ " Lastmod " ]. Innertext = Lastmod + " + 00: 00 " ;
36 Urlxmlnode. appendchild (Doc. createelement ( " Loc " , Nsurl ));
37 Urlxmlnode [ " Loc " ]. Innertext = Loc;
38 Urlxmlnode. appendchild (Doc. createelement ( " Priority " , Nsurl ));
39 Urlxmlnode [ " Priority " ]. Innertext = Priority;
40 Urlxmlnode. appendchild (Doc. createelement ( " Mobile: Mobile " , Mobileurl ));
41 Doc. documentelement. appendchild (urlxmlnode );
42 }
43 }

 

Well, there are enough words to make a gap!

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.