这篇文章也是酝酿了很久的了,在POC的时候总是有哥们儿问到拆分结果集的问题.有的时候就只能通过循环这种方式来做,苦于还没有一个合适的例子奉献给大家,今天就写一篇这样的文章和大家分享.希望可以对大家的工作,学习有所帮助.
首先介绍一下思路
1.获得类似记录的节点的count,假设我们有300条相似记录现在要拆分成1条1条的,那么这个count就是300
2.设置一个index值 这个值是0为起始的
3.进行循环 循环的条件是 index < count
4.将index所对应的条目信息send到port
5.累加index : index = index + 1;
流程截图:
大体思路如图 应该就能看的明白,这里需要一个DLL的帮助来解析XML消息,我贴一下源码,主要两个方法 一个是负责取COUNT的,一个是根据index取到内容信息:
部署的时候 只要使用FILE Adapter就可以了
看一下输入和输入文件:
input (one file)
output (two files)
惯例: 源码下载
首先介绍一下思路
1.获得类似记录的节点的count,假设我们有300条相似记录现在要拆分成1条1条的,那么这个count就是300
2.设置一个index值 这个值是0为起始的
3.进行循环 循环的条件是 index < count
4.将index所对应的条目信息send到port
5.累加index : index = index + 1;
流程截图:
大体思路如图 应该就能看的明白,这里需要一个DLL的帮助来解析XML消息,我贴一下源码,主要两个方法 一个是负责取COUNT的,一个是根据index取到内容信息:
public class Class1
{
public static int getLength(XmlDocument xd)
{
return xd.ChildNodes[0].ChildNodes.Count;
}
public static XmlDocument getInfo(XmlDocument xd,int index)
{
XmlDocument xdResult = new XmlDocument();
xdResult.InnerXml = "<ns0:Root xmlns:ns0=\"http://BizTalkLoopProject.Schema1\"><info>" + xd.ChildNodes[0].ChildNodes[index].InnerXml + "</info></ns0:Root>";
return xdResult;
}
}
{
public static int getLength(XmlDocument xd)
{
return xd.ChildNodes[0].ChildNodes.Count;
}
public static XmlDocument getInfo(XmlDocument xd,int index)
{
XmlDocument xdResult = new XmlDocument();
xdResult.InnerXml = "<ns0:Root xmlns:ns0=\"http://BizTalkLoopProject.Schema1\"><info>" + xd.ChildNodes[0].ChildNodes[index].InnerXml + "</info></ns0:Root>";
return xdResult;
}
}
部署的时候 只要使用FILE Adapter就可以了
看一下输入和输入文件:
input (one file)
<ns0:Root xmlns:ns0="http://BizTalkLoopProject.Schema1">
<info>
<a>a1</a>
<b>b1</b>
</info>
<info>
<a>a2</a>
<b>b2</b>
</info>
</ns0:Root>
<info>
<a>a1</a>
<b>b1</b>
</info>
<info>
<a>a2</a>
<b>b2</b>
</info>
</ns0:Root>
output (two files)
<?xml version="1.0" encoding="utf-8"?><ns0:Root xmlns:ns0="http://BizTalkLoopProject.Schema1">
<info>
<a>a1</a>
<b>b1</b>
</info>
</ns0:Root>
<info>
<a>a1</a>
<b>b1</b>
</info>
</ns0:Root>
<?xml version="1.0" encoding="utf-8"?><ns0:Root xmlns:ns0="http://BizTalkLoopProject.Schema1">
<info>
<a>a2</a>
<b>b2</b>
</info>
</ns0:Root>
<info>
<a>a2</a>
<b>b2</b>
</info>
</ns0:Root>
惯例: 源码下载