您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
ASP.NET中的XML表单控件
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 12:38:40
nbsp;         switch (navigator.NodeType)
            {
            case XmlNodeType.ProcessingInstruction:
                Format (navigator, "ProcessingInstruction");
                break;
            case XmlNodeType.DocumentType:
                Format (navigator, "DocumentType");
                break;
            case XmlNodeType.Document:
                Format (navigator, "Document");
                break;
            case XmlNodeType.Comment:
                Format (navigator, "Comment");
                break;
            case XmlNodeType.Element:
                Format (navigator, "Element");
                break;
            case XmlNodeType.Text:
                Format (navigator, "Text");
                break;
            case XmlNodeType.Whitespace:
                Format (navigator, "Whitespace");
                break;
            }
        }
        outputQ.Append(" ");
    }

    // Format the output
    private void Format (XmlNavigator navigator, String NodeType)
    {
        String value = String.Empty;
        String name = String.Empty;

        if (navigator.HasChildren)
        {
            name = navigator.Name;
            navigator.MoveToFirstChild();
            if (navigator.HasValue)
            {
                value = navigator.Value;
            }
        }
        else
        {
            if (navigator.HasValue)
            {
                value = navigator.Value;
                name = navigator.Name;
            }
        }
        outputQ.Append(NodeType + "<" + name + ">" + value);
        outputQ.Append(" ");
    }

// ********************************** XmlReader *****************************
    public void ShowDocument ()
    {
        outputXml = new StringBuilder();
        XmlTextReader reader = new XmlTextReader (FileLabel.Text);

        while (reader.Read())
        {
            switch (reader.NodeType)
            {
            case XmlNodeType.ProcessingInstruction:
                Format (reader, "ProcessingInstruction");
                break;
            case XmlNodeType.DocumentType:
                Format (reader, "DocumentType");
                break;
            case XmlNodeType.Comment:
                Format (reader, "Comment");
                break;
            case XmlNodeType.Element:
                Format (reader, "Element");
                break;
            case XmlNodeType.Text:
                Format (reader, "Text");
                break;
            case XmlNodeType.Whitespace:
                break;
            }
        }
        TextBox3.Text = outputXml.ToString();
    }

    protected void Format(XmlReader reader, String NodeType)
    {
        // Format the output
        for (int i=0; i < reader.Depth; i++)
        {
            outputXml.Append(' ');
        }

        outputXml.Append(reader.Prefix + NodeType + "<" + reader.Name + ">" + reader.Value);

        // Display the attributes values for the current node
        if (reader.HasAttributes)
        {
            outputXml.Append(" Attributes:");

            for (int j=0; j < reader.AttributeCount; j++)
            {
                outputXml.Append(reader[j]);
            }
        }
        outputXml.Append(" ");
    }

    /// ************************* DOM *********************************
    protected void ShowDocument(XmlNode node)
    {
        if (node != null)
            Format (node);

        if (node.HasChildNodes)
        {
            node = node.FirstChild;
          &nb

上一页  [1] [2] [3] 下一页


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |