post请求传xml参数(KissXML 生成xml文件)
来源:互联网 发布:maven 打包 java文件 编辑:程序博客网 时间:2024/06/09 23:34
最近开发中遇到一个需求,在post请求中,需要传递xml的参数!瞬间感觉不太好了,常规来说都是上传json的, 无奈也只能按照接口文档来做了!
查阅大量资料,KissXML 这个开源框架可以完美解决该问题, 下面粘出实现代码:
- (void)getSkuXmlWithVArray:(NSMutableArray *)vArray pArray:(NSMutableArray *)pArray{ DDXMLElement *AttributesElement = [DDXMLElement elementWithName:@"Attributes"]; for (NSInteger i = 0; i < pArray.count; i++) { DDXMLElement *ProductAttributeElement = [DDXMLElement elementWithName:@"ProductAttribute"]; [ProductAttributeElement addAttribute:[DDXMLNode attributeWithName:@"ID" stringValue:pArray[i]]]; DDXMLElement *ProductAttributeValueElement = [DDXMLElement elementWithName:@"ProductAttributeValue"]; DDXMLElement *ValueElement = [DDXMLElement elementWithName:@"Value" stringValue:vArray[i]]; [AttributesElement addChild:ProductAttributeElement]; [ProductAttributeElement addChild:ProductAttributeValueElement]; [ProductAttributeValueElement addChild:ValueElement]; } NSLog(@"%@", [AttributesElement XMLString]); _attributesXml = [AttributesElement XMLString];}
结果如下:
只需将其转化为字符串, 作为参数即可进行post请求!
简书传送门
阅读全文
0 0
- post请求传xml参数(KissXML 生成xml文件)
- post请求传xml参数(KissXML 生成xml文件)
- [iOS开发]如何用KissXML生成一个XML文件
- post请求xml参数的方法
- 使用KissXml解析xml
- xml解析 kissxml
- iOS 分别使用GDataXML和KissXML生成xml
- WEB POST请求XML
- 使用Alamofire进行XML参数的POST请求
- post和get请求(xml)
- POST和GET 请求 (XML)
- iOS_解析XML :KissXML、XmlReader
- web.xml文件解决post请求乱码配置
- Http post 请求发送 xml
- POST 提交XML 文件
- httpclient发送post xml请求参数据,对响应的xml做处理
- 解析HTTP POST方式请求的xml数据、本地XML文件数据, 并返回JSON字符串
- 字符串xml生成xml文件
- 用两个栈(C++)实现插入排序
- 查询在一张表不在另外一张表的记录
- 正则
- UiAutomator python+uiautomator 自动义测试框架
- 工具查看
- post请求传xml参数(KissXML 生成xml文件)
- 一年过去了,这家网站的流量竟然达到……
- WorkerMan::Worker类解析(4)
- 【codevs 2913】建筑抢修
- JAVA 编程思想第10章--内部类概要
- Android 消息机制——你真的了解Handler?
- The 3n + 1 problem
- PostGis部分点线相关函数测试
- jS中 用for循环进行对数组中数字升降排序