XmlDocument xmlDocument = new XmlDocument();
xmlDocumentLoad("testxml");
//创建新节点
XmlElement nn = xmlDocumentCreateElement("image");
nnSetAttribute("imageUrl", "jpg");
XmlNode node = xmlDocumentSelectSingleNode("content/section/page/gall/folder");//定位到folder节点
nodeAppendChild(nn);//附加新节点
//保存
xmlDocumentSave("testxml");
XElement root = XElementLoad("testxml");
foreach (XAttribute att in rootAttributes())
{
rootAdd(new XElement(attName, (string)att));
}
ConsoleWriteLine(root);
<?xml version="0" encoding="utf-8"?> <Car> <carcost> <ID>20130821133126</ID> <uptime>60</uptime> <downtime>30</downtime> <price>4</price> </carcost> <carcost> <ID>20130821014316</ID> <uptime>120</uptime> <downtime>60</downtime> <price>3</price> </carcost> <carcost> <ID>20130822043127</ID> <uptime>30</uptime> <downtime>0</downtime> <price>5</price> </carcost> <carcost> <ID>20130822043341</ID> <uptime>120以上!</uptime> <downtime>120</downtime> <price>2</price> </carcost> </Car>
class Program
{
static void Main(string[] args)
{
IList<CarCost> resultList = new List<CarCost>();
XmlDocument xmlDocument = new XmlDocument();
xmlDocumentLoad("testxml");
XmlNodeList xmlNodeList = xmlDocumentSelectSingleNode("Car")ChildNodes;
foreach (XmlNode list in xmlNodeList)
{
CarCost carcost = new CarCost
(
listSelectSingleNode("ID")InnerText,
listSelectSingleNode("uptime")InnerText,
listSelectSingleNode("downtime")InnerText,
floatParse(listSelectSingleNode("price")InnerText)
);
resultListAdd(carcost);
}
IEnumerator enumerator = resultListGetEnumerator();
while (enumeratorMoveNext())
{
CarCost carCost = enumeratorCurrent as CarCost;
ConsoleWriteLine(carCostID + " " + carCostUpTime + " " + carCostDownTime + " " + carCostPrice);
}
}
}
public class CarCost
{
public CarCost(string id, string uptime, string downtime, float price)
{
thisID = id;
thisUpTime = uptime;
thisDownTime = downtime;
thisPrice = price;
}
public string ID { get; set; }
public string UpTime { get; set; }
public string DownTime { get; set; }
public float Price { get; set; }
}
[{"TaskRoleSpaces":"","TaskRoles":"","ProxyUserID":"5d9ad5dc1c5e494db1d1b4d8d79b60a7","UserID":"5d9ad5dc1c5e494db1d1b4d8d79b60a7","UserName":"姓名","UserSystemName":"2234","OperationName":"送合同负责人","OperationValue":"同意","OperationValueText":"","SignDate":"2013-06-19 10:31:26","Comment":"同意","FormDataHashCode":"","SignatureDivID":""},{"TaskRoleSpaces":"","TaskRoles":"","ProxyUserID":"2c96c3943826ea93013826eafe6d0089","UserID":"2c96c3943826ea93013826eafe6d0089","UserName":"姓名2","UserSystemName":"1234","OperationName":"送合同负责人","OperationValue":"同意","OperationValueText":"","SignDate":"2013-06-20 09:37:11","Comment":"同意","FormDataHashCode":"","SignatureDivID":""}]
public class JobInfo
{
public string TaskRoleSpaces { get; set; }
public string TaskRoles { get; set; }
public string ProxyUserID { get; set; }
public string UserID { get; set; }
public string UserName { get; set; }
public string UserSystemName { get; set; }
public string OperationName { get; set; }
public string OperationValue { get; set; }
public string OperationValueText { get; set; }
public DateTime SignDate { get; set; }
public string Comment { get; set; }
public string FormDataHashCode { get; set; }
public string SignatureDivID { get; set; }
}
string json = @"[{'TaskRoleSpaces':'','TaskRoles':'','ProxyUserID':'5d9ad5dc1c5e494db1d1b4d8d79b60a7','UserID':'5d9ad5dc1c5e494db1d1b4d8d79b60a7','UserName':'姓名','UserSystemName':'2234','OperationName':'送合同负责人','OperationValue':'同意','OperationValueText':'','SignDate':'2013-06-19 10:31:26','Comment':'同意','FormDataHashCode':'','SignatureDivID':''},{'TaskRoleSpaces':'','TaskRoles':'','ProxyUserID':'2c96c3943826ea93013826eafe6d0089','UserID':'2c96c3943826ea93013826eafe6d0089','UserName':'姓名2','UserSystemName':'1234','OperationName':'送合同负责人','OperationValue':'同意','OperationValueText':'','SignDate':'2013-06-20 09:37:11','Comment':'同意','FormDataHashCode':'','SignatureDivID':''}]
";
List<JobInfo> jobInfoList = JsonConvertDeserializeObject<List<JobInfo>>(json);
foreach (JobInfo jobInfo in jobInfoList)
{
ConsoleWriteLine("UserName:" + jobInfoUserName + "UserID:" + jobInfoUserID);
}
public class Info
{
public string phantom { get; set; }
public string id { get; set; }
public data data { get; set; }
}
public class data
{
public int MID { get; set; }
public string Name { get; set; }
public string Des { get; set; }
public string Disable { get; set; }
public string Remark { get; set; }
}
string json = @"[{'phantom':true,'id':'20130717001','data':{'MID':1019,'Name':'aaccccc','Des':'cc','Disable':'启用','Remark':'cccc'}}]";
List<Info> infoList = JsonConvertDeserializeObject<List<Info>>(json);
foreach (Info info in infoList)
{
ConsoleWriteLine("id:" + infodataMID);
}
public class Data
{
public Boolean success { get; set; }
public Data1 data { get; set; }
}
public class Data1
{
public Int32 id { get; set; }
public string code { get; set; }
public string name { get; set; }
public string location { get; set; }
public Int32 qty { get; set; }
public List<Data2> bins { get; set; }
}
public class Data2
{
public string code { get; set; }
public string name { get; set; }
public string location { get; set; }
public Int32 qty { get; set; }
}
class Program
{
static void Main(string[] args)
{
string json = "{success:true,data:{id:100001,code:\"JTL-Z38005\",name:\"奥迪三轮毂\",location:\"A-202\",qty:100,bins:[{code:\"JTL-Z38001\",name:\"奥迪三轮毂\",location:\"A-001\",qty:100},{ code:\"JTL-Z38002\",name:\"奥迪三轮毂\",location:\"A-002\",qty:100}]}}";
Data data = JsonConvertDeserializeObject<Data>(json);
foreach (var item in datadatabins)
{
//输出:JTL-Z38001、JTL-Z38002,其它类似
ConsoleWriteLine(itemcode);
}
}
}
{\"success\":true,\"data\":{\"name\":\"张三\",\"moulds\":{\"stockImport\":true,\"stockExport\":true,\"justifyLocation\":true,\"justifyBin\":false,\"binRelease\":false}}}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string json = "{\"success\":true,\"data\":{\"name\":\"张三\",\"moulds\":{\"stockImport\":true,\"stockExport\":true,\"justifyLocation\":true,\"justifyBin\":false,\"binRelease\":false}}}";
Data data = JsonConvertDeserializeObject<Data>(json);
ConsoleWriteLine(datadatamouldsbinRelease);//输出False
}
}
public class Data
{
public Boolean success { get; set; }
public Data1 data { get; set; }
}
public class Data1
{
public string name { get; set; }
public Data2 moulds { get; set; }
}
public class Data2
{
public Boolean stockImport { get; set; }
public Boolean stockExport { get; set; }
public Boolean justifyLocation { get; set; }
public Boolean justifyBin { get; set; }
public Boolean binRelease { get; set; }
}
}
{
"success": true,
"data": {
"id": 100001,
"bin": "JIT-3JS-2K",
"targetBin": "JIT-3JS-3K",
"batchs": [
"B20140101",
"B20140102"
]
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string json = "{\"success\": true,\"data\": {\"id\": 100001,\"bin\": \"JIT-3JS-2K\",\"targetBin\": \"JIT-3JS-3K\",\"batchs\": [\"B20140101\",\"B20140102\"]}}";
Data data = JsonConvertDeserializeObject<Data>(json);
foreach (var item in datadatabatchs)
{
ConsoleWriteLine(item);//输出:B20140101、B20140102
}
}
}
public class Data
{
public Boolean success { get; set; }
public Data1 data { get; set; }
}
public class Data1
{
public Int32 id { get; set; }
public string bin { get; set; }
public string targetBin { get; set; }
public string[] batchs { get; set; }
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string j = "{success:true,data:{ bin:{code:\"JTL-Z38001\",name:\"奥迪三轮毂\",location:\"A-001\",qty:100}}}";
JObject jo = (JObject)JsonConvertDeserializeObject(j);
ConsoleWriteLine(jo);
}
}
public class Data
{
public Boolean success { get; set; }
public Data1 data { get; set; }
}
public class Data1
{
public Data2 bin { get; set; }
}
public class Data2
{
public string code { get; set; }
public string name { get; set; }
public string location { get; set; }
public Int32 qty { get; set; }
}
}
ConsoleWriteLine(jo["data"]);
ConsoleWriteLine(jo["data"]["bin"]);
ConsoleWriteLine(jo["data"]["bin"]["name"]);
{
"id": 1,
"value": "cate",
"child": [
{
"id": 1,
"value": "cate",
"child": [
]
},
{
"id": 1,
"value": "cate",
"child": [
{
"id": 2,
"value": "cate2",
"child": [
{
"id": 3,
"value": "cate3",
"child": [
]
}
]
}
]
}
]
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Data data = new Data();
dataid = 1;
datavalue = "cate";
datachild = new List<Data>()
{
new Data(){ id=1,value="cate",child=new List<Data>(){}} ,
new Data(){ id=1,value="cate",child=new List<Data>()
{
new Data()
{
id=2,
value="cate2" ,
child = new List<Data>()
{
new Data()
{
id = 3,
value = "cate3",
child = new List<Data>(){},
}
},
}
}} ,
};
//序列化为json字符串
string json = JsonConvertSerializeObject(data);
ConsoleWriteLine(json);
//反序列化为对象
Data jsonData = JsonConvertDeserializeObject<Data>(json);
}
}
public class Data
{
public int id { get; set; }
public string value { get; set; }
public List<Data> child { get; set; }
}
}
JObject jo = (JObject)JsonConvertDeserializeObject(json); ConsoleWriteLine(jo);
[
{
"downList": [],
"line": {
"Id": -1,
"Name": "admin",
"icCard": "1"
},
"upList": [
{
"endTime": "18:10",
"startTime": "06:40",
"sId": 385,
"sType": "38"
},
{
"endTime": "18:10",
"startTime": "06:40",
"sId": 1036,
"sType": "38"
}
]
},
{
"downList": [],
"line": {
"Id": -1,
"Name": "admin",
"icCard": "1"
},
"upList": [
{
"endTime": "18:10",
"startTime": "06:40",
"sId": 385,
"sType": "38"
},
{
"endTime": "18:10",
"startTime": "06:40",
"sId": 1036,
"sType": "38"
}
]
}
]
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string jsonString = "[{\"downList\": [],\"line\": {\"Id\": -1,\"Name\": \"admin\",\"icCard\": \"1\"},\"upList\": [{\"endTime\": \"18:10\",\"startTime\": \"06:40\",\"sId\": 385,\"sType\": \"38\"},{\"endTime\": \"18:10\",\"startTime\": \"06:40\",\"sId\": 1036,\"sType\": \"38\"}]},{\"downList\": [],\"line\": {\"Id\": -1,\"Name\": \"admin\",\"icCard\": \"1\"},\"upList\": [{\"endTime\": \"18:10\",\"startTime\": \"06:40\",\"sId\": 385,\"sType\": \"38\"},{\"endTime\": \"18:10\",\"startTime\": \"06:40\",\"sId\": 1036,\"sType\": \"38\"}]}]";
Data[] datas = JsonConvertDeserializeObject<Data[]>(jsonString);
foreach (Data data in datas)
{
downList[] downList = datadownList;
line line = dataline;
upList[] upLists = dataupList;
//输出
ConsoleWriteLine(stringJoin(",", lineId, lineName, lineicCard));
foreach (upList upList in upLists)
{
ConsoleWriteLine(stringJoin(",", upListendTime, upListstartTime, upListsId, upListsType));
}
ConsoleWriteLine("-----------------------------------------------");
}
}
}
public class Data
{
public downList[] downList { get; set; }
public line line { get; set; }
public upList[] upList { get; set; }
}
public class downList
{
}
public class line
{
public int Id { get; set; }
public string Name { get; set; }
public string icCard { get; set; }
}
public class upList
{
public string endTime { get; set; }
public string startTime { get; set; }
public int sId { get; set; }
public string sType { get; set; }
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有