大家好,
我现在有一个xml配置文件,里面有如下的内容:<?xml version="1.0" encoding="utf-8" ?>
<Information>
  <WebServicesURL>192.168.100.153</WebServicesURL>
</Information>假如,我现在有一个Webservice的url为:http://192.168.100.153/Mobile/Service.asmx;
我想把Mobile也添加到xml文件中。<?xml version="1.0" encoding="utf-8" ?>
<Information>
  <WebServicesURL>192.168.100.153</WebServicesURL>
  <MobileURL>Mobile</MobileURL>
</Information>那上面的红线的添加方式是否合适呢??

解决方案 »

  1.   

    xml就是传输数据内容的一个标准,你红线的部分并无不可,不过请求方接受数据后,要有自己的后处理转换成自己需要的数据格式,例如:把那个两元素组织成192.168.100.153/Mobile
      

  2.   

    修改XML
    public static void Insert(string path, string node, string element, string attribute, string value)
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(path);
                    XmlNode xn = doc.SelectSingleNode(node);
                    if (element.Equals(""))
                    {
                        if (!attribute.Equals(""))
                        {
                            XmlElement xe = (XmlElement)xn;
                            xe.SetAttribute(attribute, value);
                        }
                    }
                    else
                    {
                        XmlElement xe = doc.CreateElement(element);
                        if (attribute.Equals(""))
                        {
                            xe.InnerText = value;
                        }
                        else
                        {
                            xe.SetAttribute(attribute, value);
                        }
                        xn.AppendChild(xe);
                    }
                    doc.Save(path);
                }
                catch { }
            }是否适合根据需要
      

  3.   

    Webservice  传输格式就是XML   你的意思我也没明白
      

  4.   

    你要看读取XML需要的格式XML最基本格式只要有一个根节点 加头部 就够了。