访问单独去除属性的字符串 [英] Access a string striping out the atributes separately

查看:71
本文介绍了访问单独去除属性的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ListBox listBox1 = new ListBox();
      1      string fileName = (Server.MapPath("OrgList.xml"));
      2      XPathDocument doc = new XPathDocument(fileName);
      3     XPathNavigator nav = doc.CreateNavigator();
            // Compile a standard XPath expression
      4     XPathExpression expr;
      5      expr = nav.Compile("//DATA_RECORD");
      6     XPathNodeIterator iterator = nav.Select(expr);
            // Iterate on the node set
      7      listBox1.Items.Clear();
            try
            {
                while (iterator.MoveNext())
                {
      8             XPathNavigator nav2 = iterator.Current.Clone();
      9             listBox1.Items.Add(nav2.Value);
                                      
                    
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }


在第8行中,XPathNavigator nav2具有一个名为DATE_RECORD的节点,该节点具有名,姓和ID作为连接字符串.在执行第8行之后,我需要分别一个一个地访问那些属性.XPathNavigator的哪个成员将执行此操作?我坚持了将近两天,请帮忙.

我只是想在此方面寻求帮助,现在我不能使用diffrenet方法,因为它来不及了.


In line number 8 XPathNavigator nav2 has a node called DATE_RECORD which has first Name, lastName and an ID as a concatenated string together. I need to access those atributes one by one separately right after the execution of line 8. what member of the XPathNavigator will do that?. I''m stuck on this for almost two days please help.

I just want help on this please I can''t go to a diffrenet approach now because its too late for me to do it.

推荐答案

如果我已经阅读了您的正确发出,并且连接的字符串保存在
nav2.Value,那么您只需要根据使用的串联值进行拆分即可.

If I have read your issue correctly and the concatenated strings are held in
nav2.Value then you just need to do a split based on whatever concatenation value you have used

char seperator = '_'; // whatever you use to indicate the concatenation
string[] items = nav2.Value.Split(seperator);

//you should then have the values stored in
items[0]
items[1]
items[2]



您可以通过GetAttribute方法访问属性值吗?
nav2.GetAttribute("FirstName","URI")
Hi
You can access attribute values through GetAttribute method right?
nav2.GetAttribute("FirstName", "URI")


这篇关于访问单独去除属性的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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