国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Windows8WinRT XML數(shù)據(jù)API

Windows8WinRT XML數(shù)據(jù)API

(2013-01-15 13:24:19)
標(biāo)簽:

雜談

//添加CDATA節(jié)點(diǎn)數(shù)據(jù)至XML文件
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
   <channel>
       <title>Pay LessFor More</title>
      <link>http://paylessformore</link>
       <description>PayLess For MoreHomepage</description>
       <content>
       </content>
   </channel>
</rss>

       public asyncTask<XmlDocument> LoadXmlFile(Stringfolder, String file)
       {
          StorageFolder storageFolder = awaitPackage.Current.InstalledLocation.GetFolderAsync(folder);
          StorageFile storageFile = awaitstorageFolder.GetFileAsync(file);

          XmlLoadSettings loadSettings = new XmlLoadSettings();
          loadSettings.ProhibitDtd = false;
          loadSettings.ResolveExternals = false;

           returnawait XmlDocument.LoadFromFileAsync(storageFile,loadSettings);
       }

              try
              {
                 var xmlDoc = new XmlDocument();
                 xmlDoc.LoadXml(xml);

                 var element =xmlDoc.getElementsByTagName_r("content").Item(0);

                 String rss = scenario1RssInput.Text;
                 var cdata = xmlDoc.CreateCDataSection(rss);//create a rss CDataSection and insert into DOM tree
                 element.A(cdata);
              }
              catch (Exception exp)
              {
  Debug.WriteLine(exp.Message);
              }



//Mark HotProducts
<?xml version="1.0"encoding="utf-8"?>
<products>
    <productid="DVD-001" title="Toy story 3" hot="0">
      <price>12.99</price>
      <InStore>35</InStore>
      <Sell10day>33</Sell10day>
   </product>
    <productid="DVD-002" title="The Blind Side" hot="0">
      <price>15.99</price>
      <InStore>12</InStore>
      <Sell10day>48</Sell10day>
   </product>
</products>

           try
           {
              var doc = newXmlDocument();
              doc.LoadXml(xml);

              // Mark 'hot' attribute to'1' if 'Sell10day' is greater than 'InStore'
              var xpath ="/products/product[Sell10day>InStore]/@hot";
              var hotAttributes =doc.SelectNodes(xpath);
              for (uint index = 0; index< hotAttributes.Length; index++)
              {
                 hotAttributes.Item(index).NodeValue = "1";
              }
           }
           catch(Exception exp)
           {
  Debug.WriteLine(exp.Message);
           }


//XPath Query
<?xml version="1.0"encoding="utf-8"?>
<employees>
   <employee>
       <name>MichealJackson</name>
      <department>CustomerSupport</department>
      <startyear>2004</startyear>
   </employee>
   <employee>
       <name>AnniWang</name>
      <department>BusinessPartner</department>
      <startyear>2009</startyear>
   </employee>
   <employee>
       <name>SailYoung</name>
      <department>Consulting</department>
      <startyear>2000</startyear>
   </employee>
</employees>


           var doc =new XmlDocument();
          doc.LoadXml(xml);

           varthisYear = 2012;
           varpreviousOneYear = thisYear - 1;
           varpreviousFiveYear = thisYear - 5;
           varpreviousTenYear = thisYear - 10;

          //方式一
           var xpath= new String[3];
           // select>= 1 year and < 5 years
           xpath[0] ="descendant::employee[startyear <= " +previousOneYear + " and startyear > " +previousFiveYear + "]";
           // select>= 5 years and < 10 years
           xpath[1] ="descendant::employee[startyear <= " +previousFiveYear + " and startyear > " +previousTenYear + "]";
           // select>= 10 years
           xpath[2] ="descendant::employee[startyear <= " +previousTenYear + "]";

           var Gifts= new String[3] { "Gift Card", "XBOX", "Windows Phone" };

           var output= new StringBuilder();
           for (uinti = 0; i < 3; i++)
           {
              var employees =doc.SelectNodes(xpath[i]);
              for (uint index = 0; index< employees.Length; index++)
              {
                 var employeeName =employees.Item(index).SelectSingleNode("descendant::name");
                 var department =employees.Item(index).SelectSingleNode("descendant::department");

                 output.AppendFormat("[{0}]/[{1}]/[{2}]\n",employeeName.FirstChild.NodeValue, department.FirstChild.NodeValue,Gifts[i]);
              }
           }

          //方式二
           //varxpath = new String[3];
           ////select >= 1 year and < 5 years
           //xpath[0]= "/employees/employee[startyear <= " +previousOneYear + " and startyear > " +previousFiveYear + "]";
           ////select >= 5 years and < 10years
           //xpath[1]= "/employees/employee[startyear <= " +previousFiveYear + " and startyear > " +previousTenYear + "]";
           ////select >= 10 years
           //xpath[2]= "/employees/employee[startyear <= " +previousTenYear + "]";

           //varGifts = new String[3] { "Gift Card", "XBOX", "Windows Phone"};

           //varoutput = new StringBuilder();
           //for(uint i = 0; i < 3; i++)
           //{
           //   var employees =doc.SelectNodes(xpath[i]);
           //   for (uint index = 0; index< employees.Length; index++)
           //   {
           //      var employeeName =employees.Item(index).SelectSingleNode("name");
           //      var department =employees.Item(index).SelectSingleNode("department");

           //      output.AppendFormat("[{0}]/[{1}]/[{2}]\n",employeeName.FirstChild.NodeValue, department.FirstChild.NodeValue,Gifts[i]);
           //   }
           //}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Xml中SelectSingleNode方法中的xpath用法
XML和Xpath定位小結(jié)
Oracle分析函數(shù)
linux c libxml生成xml文件
用dom4j對(duì)帶有命名空間的xml文件使用xpath取值
JSTL與Struts的結(jié)合(五)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服