XML find the corresponding content based on the node

  String GetXmlNodeValue public (XML String, String the NodeName)
        {
            int m, n-;
            String sValue = "";
            String = xml0 XML;
            // uppercase
            XML xml.ToUpper = ();
            the NodeName = NodeName.ToUpper ();
            n-= xml.IndexOf ( "<" + the NodeName);
            // find the start character string "<" and end character "/>", and then remove its value
            IF (n-> = 0)
            {
                for (int I = n-+ the NodeName +. 1 .length; I <xml.Length; I ++)
                {
                    String xml.Substring = C (I,. 1);
                    IF (C == ">")
                    {
                        m = xml.IndexOf("</" + NodeName + ">", i + 1);
                        if (m >= 0)
                        {
                            sValue = xml0.Substring(i + 1, m - i - 1);
                            break;
                        }
                    }
                    else if (c == "/")
                    {
                        sValue = "";
                        break;
                    }
                    else if (c == " ")
                    {

                    }
                    The else
                    {
                        // abnormal end symbol
                        sValue = "";
                        BREAK;
                    }
                }
            }
            // remove spaces
            return sValue.Trim ();
        }

Guess you like

Origin blog.csdn.net/cn_514/article/details/89535322