Flattening repeating structure in biztalk

扶醉桌前 提交于 2020-01-25 09:07:05

问题


I´ve an xml instance similar to this:

<outerElementList>
    <outerElement>
        <outerID>1</outerID>
        <innerElementList>
            <innerElement>
                <innerID>10</innerID>
            </innerElement>
            <innerElement>
                <innerID>20</innerID>
            </innerElement>
        </innerElementList>
    </outerElement>
    <outerElement>
        <outerID>2</outerID>
        <innerElementList>
            <innerElement>
                <innerID>30</innerID>
            </innerElement>
            <innerElement>
                <innerID>40</innerID>
            </innerElement>
        </innerElementList>
    </outerElement>
</outerElementList>

And I need to end up with this structure:

<ElementList>
    <Element>
        <ID>1</ID>  
    </Element>
    <Element>
        <ID>2</ID>  
    </Element>
    <Element>
        <ID>10</ID> 
    </Element>
    <Element>
        <ID>20</ID> 
    </Element>
    <Element>
        <ID>30</ID> 
    </Element>
    <Element>
        <ID>40</ID> 
    </Element>
</ElementList>

I realize that I need to use a looping functoid, but I just cant seem to get it right.

Also does anyone know of a good tutorial to do these maps i C#?


回答1:


You'll want to map it like this:

Using this input:

<ns0:outerElementList xmlns:ns0="http://BizTalk_Server_Project1.Schema1">
  <outerElement>
    <outerID>1</outerID>
    <innerElementList>
      <innerElement>
        <innerID>10</innerID>
      </innerElement>
      <innerElement>
        <innerID>20</innerID>
      </innerElement>
    </innerElementList>
  </outerElement>
  <outerElement>
    <outerID>2</outerID>
    <innerElementList>
      <innerElement>
        <innerID>30</innerID>
      </innerElement>
      <innerElement>
        <innerID>40</innerID>
      </innerElement>
    </innerElementList>
 </outerElement>
</ns0:outerElementList>

I got this output:

<ns0:ElementList xmlns:ns0="http://BizTalk_Server_Project1.Schema2">
  <Element>
    <ID>1</ID>
  </Element>
  <Element>
    <ID>2</ID>
  </Element>
  <Element>
    <ID>10</ID>
  </Element>
  <Element>
    <ID>20</ID>
  </Element>
  <Element>
    <ID>30</ID>
  </Element>
  <Element>
    <ID>40</ID>
  </Element>
</ns0:ElementList>


来源:https://stackoverflow.com/questions/22035260/flattening-repeating-structure-in-biztalk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!