System.string[] 下的Split()[]函数的使用小实例

//XML文件
<?
xml version="1.0" encoding="UTF-8" ?>
- <root>
  <Time>2007/07/06 14:46</Time>
  <CurrentP>1.500</CurrentP>
  <BidP>1.450</BidP>
  <AskP>1.630</AskP>
  <Open>1.500</Open>
  <High>1.500</High>
  <Low>1.500</Low>
  <LClose>1.500</LClose>
  <Unit>5000</Unit>
  <chg>0.000</chg>
  <pchg>0.00%</pchg>
  <Volume>30000</Volume>
  <Value>45000</Value>
  <PE>17.715</PE>
  <Yield>0.005</Yield>
  <YHigh>20.000</YHigh>
  <YLow>1.490</YLow>
  <TotalValue>185400009</TotalValue>
 </root>

  
 string FilePath = @"D:/Test/0817.xml";

   /* 加载XML并输出 */
   XmlDocument doc = new XmlDocument();
   doc.Load(FilePath);

   XmlElement root = doc.DocumentElement;
   XmlNode current = root.SelectSingleNode("CurrentP");

   CurrentP = current.InnerText.ToString();
   Integer = CurrentP.Split('.')[0];
   Decimal = CurrentP.Split('.')[1];

输出结果:Integer=1;
         Decimal=500;

你可能感兴趣的:(String)