XML和DataSet转换

DeerFlow 系列教程 第十四篇 | IM 渠道集成——让 DeerFlow 接入飞书、企微、Slack、Telegram DeerFlow 系列教程 第十四篇本篇教程继续,全面剖析 DeerFlow 的 IM 渠道集成方案。我们将深入理解 Channel 抽象层设计、MessageBus 消息总线机制、ChannelManager 调度循环、四大 IM 平台(飞书、企业微信、Slack、Telegram)的适配实现,以及从 IM 消息到 Agent 响应再到 IM 回复的完整消息流过程。 阅读详情

用.NET可以方便的操作XML,当做数据源

*当XML转到DataSet的时候会遵循如下几个原则
*具有属性的元素和具有自节点的元素会变成表
*重复的元素会变成列

这里使用GridView绑定
  XML:

<?xml version="1.0" standalone="yes"?>
<family>
  
<relation="myfather">
    
<name></name>
    
<sex>man</sex>
    
<age>60</age>
  
</p>
  
<relation="mymather">
    
<name></name>
    
<sex>women</sex>
    
<age>55</age>
  
</p>
</family>
 读取:
 protected void Page_Load(object sender, EventArgs e)
    {
        bind();
    }
  
protected void bind()
    {
        DataSet ds 
= new DataSet();
        ds.ReadXml(Server.MapPath(
"../people.xml"));
        GridView1.DataSource 
= ds.Tables[0].DefaultView;
        GridView1.DataBind();

        Session[
"ds"= ds;

    }
添加:
protected void Button1_Click(object sender, EventArgs e)
    
{
       
     DataSet ds 
= (DataSet)Session["ds"];
        
string name = this.TextBox1.Text.ToString();
        
string age = this.TextBox2.Text.ToString();
        
string sex = this.TextBox3.Text.ToString();
        
string relation = this.RadioButtonList1.SelectedValue.ToString();

        DataRow dr 
= ds.Tables[0].NewRow();

        dr[
"relation"= relation;
        dr[
"age"= age;
        dr[
"sex"= sex;
        dr[
"name"= name;
        ds.Tables[
0].Rows.Add(dr);

     Session[
"ds"= ds;
        ds.WriteXml(Server.MapPath(
"../people.xml")); 
     bind();
    }

删除:

  protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DataSet ds 
= (DataSet)Session["ds"];
        ds.Tables[
0].Rows.Remove(ds.Tables[0].Rows[e.RowIndex]);
        Session[
"ds"= ds;
        ds.WriteXml(Server.MapPath(
"../people.xml"));
        bind();
    }

修改:
 

FPGA 学习笔记:Vitis IDE launch failed 的解决方法 阅读详情

相关推荐

Delphi7调C#Webservice用返回ClientDataSet XML格式数据

Delphi7调C#Webservice用返回ClientDataSet XML格式数据

Delphi 6 XML映象工具

Delphi 6 含有许多更新更强的XML支持功能,增加了XML文件编程,XML数据绑定向导,XML映象BizSnap(SOAP/XML Web服务)。本文是三篇论述Delphi 6中XML功能系列文章的第三篇,也是最后一篇,论述Delphi 6中的XML映象工具,也称之为XML映象器(XML Mapper)。XML映象器可以单独打开或者在IDE的工具(Tools)菜单中打开映象器(XML

ChinaOk的专栏 1734

LoadRunner11对服务器进行压力负载测试总结

LoadRunner11对服务器进行压力负载测试总结,可以进行参考

XMLDataSet的相互转换

送给大家一个XMLDataSet的相互转换的类: XmlDatasetConvert 该类提供了四种方法: 1、将xml对象内容字符串转换DataSet 2、将xml文件转换DataSet 3、将DataSet转换xml对象字符串 4、将DataSet转换xml文件 粘贴自别的网站。可以正常使用。 using Syste...

weixin_30561425的博客 216

XMLDataSet的相互转换

XmlDatasetConvert 该类提供了四种方法: 1、将xml对象内容字符串转换DataSet 2、将xml文件转换DataSet 3、将DataSet转换xml对象字符串 4、将DataSet转换xml文件 XmlDatasetConvert.cs using System; using System.Collections.Generic; using Sys

蓝叶菱的专栏 1366

XMLDataSet使用实例及注意事项

方法如下: public static DataSet ConvertXMLToDataSet(string xmlData) throws Exception { StringReader stream = null; XmlTextReader reader = null; try { DataSet xmlDs = new Dat...

代码啥东东 1025

java dataset xml_XMLDataSet的相互转换

1 //XmlDatasetConvert.cs23 using System;4 using System.Collections.Generic;5 using System.Text;6 using System.Data;7 using System.IO;8 using System.Xml;910 namespace XmlDesign11 {12 class XmlDatas...

weixin_39541869的博客 197

java dataset xml_DataSetxml文件的互相转换

http://www.cnblogs.com/long2006sky/articles/1258731.htmlDataSet转换xml文件//将DataSet转换xml文件private static void ConvertDataSetToXMLFile(DataSet xmlDS, string xmlFile){MemoryStream stream = null;XmlTextWr...

weixin_39676242的博客 209

DataSetxml的互相转换

<br />一、xml转换为相应的DataSet <br />1、将xml字符串内容转换DataSet<br />示例:<br />/// </summary><br />/// xmlStr:对应的xml字符串<br />/// </summary><br />public  DataSet  XmlToDataSet(String  xmlStr)<br />{<br />StringReader  strReader;<br />XmlTextReader  xtReader;<br />DataS

壊壊娚孩的专栏 768

java dataset xml_DataSetXml文件的互相转换

DataSet转换xml文件//将DataSet转换xml文件private static void ConvertDataSetToXMLFile(DataSet xmlDS, string xmlFile){MemoryStream stream = null;XmlTextWriter writer = null;try{stream = new MemoryStream();//从st...

weixin_39915505的博客 187

DataSet转换XML转换DataSet

<br /><br />htm:<br /><%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html

577

xml文件转换DataSet

        ///         /// 将xml文件转换DataSet        ///         ///         ///         public  DataSet ConvertXMLFileToDataSet(string xmlFile)        {            StringReader stream = null;            X

wangygang的专栏 1013

java dataset xml_XMLDataSet的相互转换-Java架构师必看

送给大家一个XMLDataSet的相互转换的类:XmlDatasetConvert该类提供了四种网络送给大家一个XMLDataSet的相互转换的类:XmlDatasetConvert 该类提供了四种方法:1、将xml对象内容字符串转换DataSet2、将xml文件转换DataSet3、将DataSet转换xml对象字符串4、将DataSet转换xml文件XmlDatasetConver...

weixin_39595537的博客 270

.net DataSetXML的相互转换

1。DataSetXML #region DataToXml /// /// 将DataSet对象转换XML字符串 /// /// DataSet对象 /// XML字符串 public string DataToXml(DataSet ds) { if (ds != null && ds.Tables.Count > 0) { MemoryStream ms = n

aiouwen521的专栏 2498

XMLDataSet的互(1)--基础XML

XMLDataSet的互(1)--基础XML 最近一段时间一直在做这方面的东西。由于公司开发需要,业务层数据层全部封装成COM+组件,而同时还需要保证返回的数据必须是通用类型。因为就想到了XML。 可以说,XMLDataSet进行交互是非常容易的,无论是XML文件还是XML字符串。而我们现在主要用的都是XML字符串的方式。即使用DataSet.GetX...

weixin_30472035的博客 185

XMLDataSet

XML字符串DataSet public static DataSet XmlToDataSet(string strXml) { DataSet ds = new DataSet(); StringReader sr = new StringReader(strXml); XmlTextR

风之领域 874

dataset中有多个表,返回XML字符串设置主从关系

<?xml version="1.0" encoding="utf-8" ?> <string xmlns="http://tempuri.org/"> <Getstore> <Goods> <product_no>FB22S58613</product_no> ...

weixin_30236595的博客 199

XmlDataDocument与DataSet相互

1. View Code 1 using System.Text; 2 using System.IO; 3 4 XmlNode xmlNode1; 5 XmlDataDocument xd=new XmlDataDocument(); 6 StringBuilder xmlString1; 7 8 xmlNode1=DataSet1;//DataSet1为返回的数据集 ...

weixin_33881753的博客 165

delphi 通过 TXMLTransformProvider 或 TXMLTransform 都可以让 TClientDataSet 读写此 XML

TClientDataSet 可以直接存取的 XML 有自己的格式规范, 存取其他格式 XML 需要相应的映射文件(*.xtr).这种 *.xtr 文件是用 XML Mapper(Delphi 自带, 可从开始菜单或 IDE -> Tools 启动)制作的.一般会需要两个 *.xtr 文件, 一个用于读取(例子中是: ToDp.xtr), 一个用于写入(例子中是: ToXml.xtr).可以通过 *.xtr 文件只读写源 XML 中的部分数据, 如果读取过于复杂的 XML 会生成嵌套的 DataSet

861
上一篇: 使用存储过程检测用户名是否存在
下一篇: Ajax.net中使用PopupControlExtender
mingzhecode
博客等级 码龄19年 13粉丝 42原创
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值