Asp.net .net到coldfusion web服务xml解析

Asp.net .net到coldfusion web服务xml解析,asp.net,xml,web-services,coldfusion,Asp.net,Xml,Web Services,Coldfusion,我几乎完成了这个项目。考虑到以下xml: <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <debtor xmlns="http://tempuri.org/Database.xsd"> <Customer diffgr:id="Custome

我几乎完成了这个项目。考虑到以下xml:

<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    <debtor xmlns="http://tempuri.org/Database.xsd">
      <Customer diffgr:id="Customer1" msdata:rowOrder="0" diffgr:hasErrors="true">
        <SeqNo>-1</SeqNo>
        <AccGroup>1</AccGroup>
        <AccountTypeID>1</AccountTypeID>
        <CompaniesOfficeID>-4</CompaniesOfficeID>
        <DOB />
        <SignupDate>18/04/2007</SignupDate>
        <DeferredDate />
        <TeleSalesNo>5</TeleSalesNo>
        <PIN>4433</PIN>
        <Name>MR DAVID GETTI</Name>
        <Salutation>MR</Salutation>
        <FirstName>DAVID</FirstName>
        <LastName>GETTI</LastName>
        <Phone>64 7 555 522</Phone>
        <Fax />
        <CellPhone>64 25 999 999</CellPhone>
        <Email>dave.getti@cpass.net.nz</Email>
        <AfterHrs_Contact />
        <SalesNo>0</SalesNo>
        <CreditStatus>1</CreditStatus>
        <RefGroupNo>0</RefGroupNo>
        <PriceNo>-1</PriceNo>
        <SmartLineProvider>-1</SmartLineProvider>
        <Contact>DAVID GETTI</Contact>
        <CustomerCode>1111111</CustomerCode>
        <HasCellPhone>false</HasCellPhone>
        <InvoiceOptions>12</InvoiceOptions>
        <TradingAs>MR DAVID GETTI</TradingAs>
        <FranchiseCode>-1</FranchiseCode>
        <Existing>true</Existing>
        <Address diffgr:id="Address1" msdata:rowOrder="0">
          <SeqNo>-1</SeqNo>
          <CustomerSeqNo>-1</CustomerSeqNo>
          <Show>30</Show>
          <TypeSelected>2</TypeSelected>
          <Name>PostalAddress</Name>
          <AddressNumber />
          <Address1>88 Blue Lane East</Address1>
          <Address2>REMA</Address2>
          <Address3>AKL</Address3>
          <Address4 />
          <PostCode>1050</PostCode>
          <LocationCode>0</LocationCode>
          <AgentID>0</AgentID>
        </Address>
        <Address diffgr:id="Address2" msdata:rowOrder="1">
          <SeqNo>-2</SeqNo>
          <CustomerSeqNo>-1</CustomerSeqNo>
          <Show>10</Show>
          <TypeSelected>2</TypeSelected>
          <Name>PhysicalAddress</Name>
          <AddressNumber />
          <Address1>44 OHINA STREET</Address1>
          <Address2>REMA</Address2>
          <Address3>AKL</Address3>
          <Address4 />
          <PostCode>1098</PostCode>
          <LocationCode>1</LocationCode>
          <AgentID>1</AgentID>
        </Address>

-1
1.
1.
-4
18/04/2007
5.
4433
格蒂先生
先生
大卫
盖蒂
64 7 555 522
64 25 999 999
戴夫。getti@cpass.net.nz
0
1.
0
-1
-1
大卫盖蒂
1111111
错误的
12
格蒂先生
-1
符合事实的
-1
-1
30
2.
邮资
蓝巷东88号
雷马
AKL
1050
0
0
-2
-1
10
2.
物理地址
大华街44号
雷马
AKL
1098
1.
1.
我可以使用以下代码访问除地址详细信息之外的所有数据并填充查询对象:

<cfset Local.xRows = Local.xData["diffgr:diffgram"]["debtor"] />
<cfloop from="1" to="#arrayLen(Local.xRows.xmlChildren)#" index="Local.i">
   <cfset Local.thisRow = Local.xRows.xmlChildren[Local.i] />
    <cfset Local.tableName = Local.thisRow.xmlName />
    <cfset queryAddRow(Local.result[Local.tableName], 1) />

    <cfloop from="1" to="#arrayLen(Local.thisRow.xmlChildren)#" index="Local.j">
        <cfif listfindnocase(vCols,Local.thisRow.xmlChildren[Local.j].xmlName)>
           <cfset querySetCell(Local.result[Local.tableName], Local.thisRow.xmlChildren[Local.j].xmlName, Local.thisRow.xmlChildren[Local.j].xmlText, Local.result[Local.tableName].recordCount) />
        </cfif>
    </cfloop>
</cfloop>

但是,我一直在学习如何访问主地址节点下的各个地址详细信息节点:

<Address diffgr:id="Address1" msdata:rowOrder="0">


任何帮助都将不胜感激。

我认为您正在尝试使用绝对引用来引用这些单独的节点,而不是使用cfloop更容易获得的本地引用

<cfset xmlCustomerInfo = xmlDoc.info[ "Customer" ][ Local.i ] />
<cfset arrAddressList = xmlCustomerInfo[ "Address" ] />

<cfloop
    index="Local.j"
    from="1"
    to="#ArrayLen( arrAddressList )#"
    step="1">

    <cfset innerAddressNode = arrAddressList[ Local.j ] />

</cfloop>

下面是一些在Coldfusion中解析XML的方法


警告:代码未经测试,仅基于您所展示的内容以及coldfusion解析Xml文档的方式。

我希望您真的没有向全世界提供Getti先生的电子邮件、电话号码和家庭地址。是的,从姓名到地址,我都搞砸了。他永远不会被认出来!多谢多米尼克,我最终以这个为出发点到达了那里。很高兴能帮上忙!请随时发布您所做的事情,以便我们社区能够从中学习。谢谢!