我需要一些关于String [求助]的帮助 [英] I need some help about String[SOLVED]

查看:98
本文介绍了我需要一些关于String [求助]的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的xml代码如下所示。 x366:D

Hello I have xml code look like this. x366 :D

<prayertimes dayofyear="192" day="11" month="7">
3:18	3:39	5:35	6:28	12:58	13:21	17:20	18:33	20:01	20:46	21:47	22:42	23:00	12:27	22.1036908	9.6633100
</prayertimes>



我只想读20:46(第十个)。我能看懂吗?如果可能的话怎么做?


I want read "20:46" only(tenth one). Can i read this? If possible how?

推荐答案

将XML元素的值读入字符串,然后用户使用Split功能

看看如何你已粘贴它,我想它是一个制表符分隔字符串。

您可以使用拆分功能按标签分割,然后只读取第10个条目。
Read the value of the XML element into a string, then user the "Split" function
Looking at how you have pasted it, I imagine it is a tab deliminated string.
You can use the split function to split by tab and then just read the 10th entry.


如果你想要总是相同的位置那么这将帮助你



if you want always the same position then this will help you

var xdoc = XDocument.Load(PathOfYourXmlFile);
      var companies = xdoc.Descendants("prayertimes").Select(c => (string)c).ToArray();
      string value = companies[0].TrimStart();
      string[] split = value.Split('\t');
      string ouptut = split[9];



输出字符串将保持你想要的20:46


这篇关于我需要一些关于String [求助]的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆