2011-10-06 28 views
0

示例XML:如何創建XML其中有許多命名空間,它像下面

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dp="http://www.datapower.com/schemas/management"> 
    soapenv:Body> 
     <recordClaim xmlns="http://webservices.zurich.com/zsoa/fig/claimmanagement/lossnotification-v1_0"> 
     <requestHeader> 
      <ns1:userId 
      <ns2:systemDateTime xmlns:ns2="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/zsoa">2010-04-21T17:52:53.156Z</ns2:systemDateTime> 
      <ns3:systemName xmlns:ns3="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/zsoa">System</ns3:systemName> 
      <ns4:messageReference xmlns:ns4="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/zsoa">P-1618 20100421T175253.448 GMT</ns4:messageReference> 
      <ns5:functionName xmlns:ns5="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/zsoa">IB_CS_ClaimReg_ClaimInsert</ns5:functionName> 
      <ns6:transactionStartDateTime xmlns:ns6="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/zsoa">2010-04-21T17:52:53.156Z</ns6:transactionStartDateTime> 
     </requestHeader> 
     <entityName>Claim</entityName> 
     <newClaim> 
      <ns7:claimSource xmlns:ns7="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim">FNOL</ns7:claimSource> 
      <ns8:eventNumber xmlns:ns8="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim">2000059951</ns8:eventNumber> 
      <ns9:policyExternalReference xmlns:ns9="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"/> 
      <ns10:policy xmlns:ns10="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns11:basicAutoInsurancePolicy xmlns:ns11="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns11:houseHoldNumber/> 
        <ns11:manualEntryIndicator>false</ns11:manualEntryIndicator> 
        <ns11:multicarPolicyIndicator>false</ns11:multicarPolicyIndicator> 
        <ns11:agentContact> 
        <ns12:agentCode xmlns:ns12="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">96</ns12:agentCode> 
        <ns13:agentDistrictCode xmlns:ns13="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">76</ns13:agentDistrictCode> 
        <ns14:agentName xmlns:ns14="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns14:firstName>Steve</ns14:firstName> 
         <ns14:lastName>Wilson</ns14:lastName> 
        </ns14:agentName> 
        <ns15:agentPhoneNumber xmlns:ns15="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns15:telephoneNumber> 
          <ns15:contactPointAsString>9158332201</ns15:contactPointAsString> 
         </ns15:telephoneNumber> 
        </ns15:agentPhoneNumber> 
        <ns16:agentRegionCode xmlns:ns16="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">35</ns16:agentRegionCode> 
        </ns11:agentContact> 
        <ns11:basicAutoInsurancePolicySummary> 
        <ns11:basicPolicy> 
         <ns11:alternativeReference/> 
         <ns11:policyDescription>Auto</ns11:policyDescription> 
         <ns11:policyNumber>0041919349</ns11:policyNumber> 
         <ns11:policyState>TX</ns11:policyState> 
         <ns11:policyStateCode>35</ns11:policyStateCode> 
         <ns11:policyStatus>SOK</ns11:policyStatus> 
         <ns11:policyType>Homeowners</ns11:policyType> 
         <ns11:umbrellaPolicyIndicator>false</ns11:umbrellaPolicyIndicator> 
        </ns11:basicPolicy> 
        </ns11:basicAutoInsurancePolicySummary> 
        <ns11:insured> 
        <ns17:basicPersonContactPoint xmlns:ns17="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns17:basicElectronicAddress> 
          <ns17:electronicAddress> 
           <ns17:electronicType>Proprietary</ns17:electronicType> 
          </ns17:electronicAddress> 
         </ns17:basicElectronicAddress> 
         <ns17:basicPerson> 
          <ns17:person> 
           <ns18:typeName xmlns:ns18="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Individual</ns18:typeName> 
          </ns17:person> 
          <ns17:personName> 
           <ns17:firstName>ROBERT</ns17:firstName> 
           <ns17:lastName>ARMSTRONG</ns17:lastName> 
          </ns17:personName> 
         </ns17:basicPerson> 
         <ns17:basicTelephoneNumber> 
          <ns17:isPrimaryTelephoneNumber>true</ns17:isPrimaryTelephoneNumber> 
          <ns17:telephoneNumber> 
           <ns19:typeName xmlns:ns19="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Home</ns19:typeName> 
           <ns17:contactPointAsString>2112122112</ns17:contactPointAsString> 
           <ns17:extension/> 
          </ns17:telephoneNumber> 
         </ns17:basicTelephoneNumber> 
        </ns17:basicPersonContactPoint> 
        </ns11:insured> 
       </ns11:basicAutoInsurancePolicy> 
      </ns10:policy> 
      <ns20:policy xmlns:ns20="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns21:basicAutoInsurancePolicy xmlns:ns21="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns21:houseHoldNumber/> 
        <ns21:manualEntryIndicator>false</ns21:manualEntryIndicator> 
        <ns21:multicarPolicyIndicator>false</ns21:multicarPolicyIndicator> 
        <ns21:agentContact> 
        <ns22:agentCode xmlns:ns22="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">96</ns22:agentCode> 
        <ns23:agentDistrictCode xmlns:ns23="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">76</ns23:agentDistrictCode> 
        <ns24:agentName xmlns:ns24="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns24:firstName>Steve</ns24:firstName> 
         <ns24:lastName>Wilson</ns24:lastName> 
        </ns24:agentName> 
        <ns25:agentPhoneNumber xmlns:ns25="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns25:telephoneNumber> 
          <ns25:contactPointAsString>9158332201</ns25:contactPointAsString> 
         </ns25:telephoneNumber> 
        </ns25:agentPhoneNumber> 
        <ns26:agentRegionCode xmlns:ns26="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">35</ns26:agentRegionCode> 
        </ns21:agentContact> 
        <ns21:basicAutoInsurancePolicySummary> 
        <ns21:basicPolicy> 
         <ns21:alternativeReference/> 
         <ns21:policyDescription>Auto</ns21:policyDescription> 
         <ns21:policyNumber>0041919349</ns21:policyNumber> 
         <ns21:policyState>TX</ns21:policyState> 
         <ns21:policyStateCode>35</ns21:policyStateCode> 
         <ns21:policyStatus>SOK</ns21:policyStatus> 
         <ns21:policyType>Homeowners</ns21:policyType> 
         <ns21:umbrellaPolicyIndicator>false</ns21:umbrellaPolicyIndicator> 
        </ns21:basicPolicy> 
        </ns21:basicAutoInsurancePolicySummary> 
        <ns21:insured> 
        <ns27:basicPersonContactPoint xmlns:ns27="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns27:basicElectronicAddress> 
          <ns27:electronicAddress> 
           <ns27:electronicType>Proprietary</ns27:electronicType> 
          </ns27:electronicAddress> 
         </ns27:basicElectronicAddress> 
         <ns27:basicPerson> 
          <ns27:person> 
           <ns28:typeName xmlns:ns28="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Individual</ns28:typeName> 
          </ns27:person> 
          <ns27:personName> 
           <ns27:firstName>ROBERT</ns27:firstName> 
           <ns27:lastName>ARMSTRONG</ns27:lastName> 
          </ns27:personName> 
         </ns27:basicPerson> 
         <ns27:basicTelephoneNumber> 
          <ns27:isPrimaryTelephoneNumber>true</ns27:isPrimaryTelephoneNumber> 
          <ns27:telephoneNumber> 
           <ns29:typeName xmlns:ns29="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Home</ns29:typeName> 
           <ns27:contactPointAsString>2112122112</ns27:contactPointAsString> 
           <ns27:extension/> 
          </ns27:telephoneNumber> 
         </ns27:basicTelephoneNumber> 
        </ns27:basicPersonContactPoint> 
        </ns21:insured> 
       </ns21:basicAutoInsurancePolicy> 
      </ns20:policy> 
      <ns30:policy xmlns:ns30="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns31:basicAutoInsurancePolicy xmlns:ns31="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns31:houseHoldNumber/> 
        <ns31:manualEntryIndicator>false</ns31:manualEntryIndicator> 
        <ns31:multicarPolicyIndicator>false</ns31:multicarPolicyIndicator> 
        <ns31:agentContact> 
        <ns32:agentCode xmlns:ns32="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">96</ns32:agentCode> 
        <ns33:agentDistrictCode xmlns:ns33="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">76</ns33:agentDistrictCode> 
        <ns34:agentName xmlns:ns34="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns34:firstName>Steve</ns34:firstName> 
         <ns34:lastName>Wilson</ns34:lastName> 
        </ns34:agentName> 
        <ns35:agentPhoneNumber xmlns:ns35="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns35:telephoneNumber> 
          <ns35:contactPointAsString>9158332201</ns35:contactPointAsString> 
         </ns35:telephoneNumber> 
        </ns35:agentPhoneNumber> 
        <ns36:agentRegionCode xmlns:ns36="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">35</ns36:agentRegionCode> 
        </ns31:agentContact> 
        <ns31:basicAutoInsurancePolicySummary> 
        <ns31:basicPolicy> 
         <ns31:alternativeReference>HX011081</ns31:alternativeReference> 
         <ns31:policyDescription>BASIC FORM (TEXAS)</ns31:policyDescription> 
         <ns31:policyNumber>0929624151</ns31:policyNumber> 
         <ns31:policyState>TX</ns31:policyState> 
         <ns31:policyStateCode>35</ns31:policyStateCode> 
         <ns31:policyStatus>SOK</ns31:policyStatus> 
         <ns31:policyType>Homeowners</ns31:policyType> 
         <ns31:umbrellaPolicyIndicator>false</ns31:umbrellaPolicyIndicator> 
        </ns31:basicPolicy> 
        </ns31:basicAutoInsurancePolicySummary> 
        <ns31:insured> 
        <ns37:basicPersonContactPoint xmlns:ns37="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns37:basicElectronicAddress> 
          <ns37:electronicAddress> 
           <ns37:electronicType>Proprietary</ns37:electronicType> 
          </ns37:electronicAddress> 
         </ns37:basicElectronicAddress> 
         <ns37:basicPerson> 
          <ns37:person> 
           <ns38:typeName xmlns:ns38="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Individual</ns38:typeName> 
          </ns37:person> 
          <ns37:personName> 
           <ns37:firstName>ROBERT</ns37:firstName> 
           <ns37:lastName>ARMSTRONG</ns37:lastName> 
          </ns37:personName> 
         </ns37:basicPerson> 
         <ns37:basicTelephoneNumber> 
          <ns37:isPrimaryTelephoneNumber>true</ns37:isPrimaryTelephoneNumber> 
          <ns37:telephoneNumber> 
           <ns39:typeName xmlns:ns39="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Home</ns39:typeName> 
           <ns37:contactPointAsString>2112122112</ns37:contactPointAsString> 
           <ns37:extension/> 
          </ns37:telephoneNumber> 
         </ns37:basicTelephoneNumber> 
        </ns37:basicPersonContactPoint> 
        </ns31:insured> 
       </ns31:basicAutoInsurancePolicy> 
      </ns30:policy> 
      <ns40:claim xmlns:ns40="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns40:claimAlternateReference>P-1618</ns40:claimAlternateReference> 
       <ns40:claimExternalReference/> 
       <ns40:dateOfDiscovery>2010-01-01T00:00:00.000Z</ns40:dateOfDiscovery> 
       <ns40:manualEntryIndicator>false</ns40:manualEntryIndicator> 
       <ns40:rekeyedClaimExternalReference>HX011081</ns40:rekeyedClaimExternalReference> 
       <ns40:timeZone>Central Time</ns40:timeZone> 
       <ns40:isDualClaim>false</ns40:isDualClaim> 
       <ns40:isInformationOnly>false</ns40:isInformationOnly> 
       <ns40:isPremise>true</ns40:isPremise> 
       <ns40:isAutoSubmit>true</ns40:isAutoSubmit> 
       <ns40:claimFolder> 
        <ns40:policyNumber>0929624151</ns40:policyNumber> 
       </ns40:claimFolder> 
      </ns40:claim> 
      <ns41:fullLossEvent xmlns:ns41="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns41:lossDateTime>2010-01-01T09:00:00.000Z</ns41:lossDateTime> 
       <ns41:lossDescriptionValue/> 
       <ns41:lossLocation/> 
       <ns41:lossReportedBy>ROBERT ARMSTRONG</ns41:lossReportedBy> 
       <ns41:lossReportedDateTime>2010-04-21T17:48:06.466Z</ns41:lossReportedDateTime> 
       <ns41:lossSummary>Freeze-Slab/Foundation Damage</ns41:lossSummary> 
       <ns41:lossTypeCode>Property</ns41:lossTypeCode> 
       <ns41:reportedByAILR>ROBERT ARMSTRONG</ns41:reportedByAILR> 
       <ns41:locationAddress> 
        <ns42:addressLines xmlns:ns42="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"/> 
        <ns43:isPrimaryAddress xmlns:ns43="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">true</ns43:isPrimaryAddress> 
        <ns44:postalAddress xmlns:ns44="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
        <ns44:city/> 
        <ns44:country>USA</ns44:country> 
        <ns44:postalCode/> 
        <ns44:region>CA</ns44:region> 
        </ns44:postalAddress> 
       </ns41:locationAddress> 
       <ns41:lossEvent> 
        <ns45:typeName xmlns:ns45="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">In home</ns45:typeName> 
        <ns46:description xmlns:ns46="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/activityconditionplace">sdfdsfdsfdsf</ns46:description> 
        <ns47:externalReference xmlns:ns47="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/activityconditionplace"/> 
       </ns41:lossEvent> 
      </ns41:fullLossEvent> 
      <ns48:contactInfo xmlns:ns48="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/claim"> 
       <ns48:alternativeReference>Individual</ns48:alternativeReference> 
       <ns48:citationNumber/> 
       <ns48:comments/> 
       <ns48:insuranceCarrierClaimNumber/> 
       <ns48:insuranceCarrierPolicyNumber/> 
       <ns48:insuredBy/> 
       <ns48:isInterpreterNeededIndicator>false</ns48:isInterpreterNeededIndicator> 
       <ns48:language>English</ns48:language> 
       <ns48:relationshipToInsured>Self</ns48:relationshipToInsured> 
       <ns48:isInjured>false</ns48:isInjured> 
       <ns48:isOtherCarrier>false</ns48:isOtherCarrier> 
       <ns48:isPedestrianIndicator>false</ns48:isPedestrianIndicator> 
       <ns48:fullpartyrolepersonview> 
        <ns49:personRole xmlns:ns49="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party">Insured</ns49:personRole> 
        <ns50:basicPersonContactPoint xmlns:ns50="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
        <ns50:basicElectronicAddress> 
         <ns50:emailPreferredIndicator>false</ns50:emailPreferredIndicator> 
         <ns50:electronicAddress> 
          <ns50:contactPointAsString/> 
          <ns50:electronicType>Proprietary</ns50:electronicType> 
         </ns50:electronicAddress> 
        </ns50:basicElectronicAddress> 
        <ns50:basicPerson> 
         <ns50:personName> 
          <ns50:firstName>ROBERT</ns50:firstName> 
          <ns50:lastName>ARMSTRONG</ns50:lastName> 
          <ns50:middleName/> 
         </ns50:personName> 
        </ns50:basicPerson> 
        <ns50:basicPostalAddress> 
         <ns50:addressLines>6808 CAN CUN LN</ns50:addressLines> 
         <ns50:careOfAddressee/> 
         <ns50:isPrimaryAddress>false</ns50:isPrimaryAddress> 
         <ns50:postalAddress> 
          <ns51:typeName xmlns:ns51="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Mailing</ns51:typeName> 
          <ns50:statusAsString>Verified</ns50:statusAsString> 
          <ns50:city>EL PASO</ns50:city> 
          <ns50:country>USA</ns50:country> 
          <ns50:houseNumber/> 
          <ns50:postalCode>79912</ns50:postalCode> 
          <ns50:postalCodeExtension>2327</ns50:postalCodeExtension> 
          <ns50:region>TX</ns50:region> 
          <ns50:street>6808</ns50:street> 
         </ns50:postalAddress> 
        </ns50:basicPostalAddress> 
        <ns50:basicTelephoneNumber> 
         <ns50:isPrimaryTelephoneNumber>true</ns50:isPrimaryTelephoneNumber> 
         <ns50:telephoneNumber> 
          <ns50:contactPointAsString>2112122112</ns50:contactPointAsString> 
         </ns50:telephoneNumber> 
        </ns50:basicTelephoneNumber> 
        <ns50:basicTelephoneNumber> 
         <ns50:telephoneNumber> 
          <ns52:typeName xmlns:ns52="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/common">Home</ns52:typeName> 
          <ns50:contactPointAsString>2112122112</ns50:contactPointAsString> 
         </ns50:telephoneNumber> 
        </ns50:basicTelephoneNumber> 
        </ns50:basicPersonContactPoint> 
       </ns48:fullpartyrolepersonview> 
       <ns48:property> 
        <ns53:description xmlns:ns53="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement">sdfsdfsdf</ns53:description> 
        <ns54:propertyType xmlns:ns54="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement">Building</ns54:propertyType> 
        <ns55:propertyDamages xmlns:ns55="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns55:alternativeReference>Building</ns55:alternativeReference> 
        <ns55:description>Attic</ns55:description> 
        </ns55:propertyDamages> 
        <ns56:propertyDamages xmlns:ns56="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns56:alternativeReference>Building</ns56:alternativeReference> 
        <ns56:description>Bathroom 1</ns56:description> 
        </ns56:propertyDamages> 
        <ns57:propertyDamages xmlns:ns57="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns57:alternativeReference>Building</ns57:alternativeReference> 
        <ns57:description>Bathroom 2</ns57:description> 
        </ns57:propertyDamages> 
        <ns58:propertyDamages xmlns:ns58="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns58:alternativeReference>Building</ns58:alternativeReference> 
        <ns58:description>Bathroom 3</ns58:description> 
        </ns58:propertyDamages> 
       </ns48:property> 
       <ns48:property> 
        <ns59:description xmlns:ns59="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"/> 
        <ns60:propertyType xmlns:ns60="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement">Contents</ns60:propertyType> 
        <ns61:locationAddress xmlns:ns61="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns62:postalAddress xmlns:ns62="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/party"> 
         <ns62:city/> 
         <ns62:country>USA</ns62:country> 
         <ns62:houseNumber/> 
         <ns62:postalCode/> 
         <ns62:region/> 
         <ns62:street/> 
        </ns62:postalAddress> 
        </ns61:locationAddress> 
        <ns63:propertyDamages xmlns:ns63="http://schemas.zurich.com/zsoa/fig/claimmanagement/2009/01/financialservicesagreement"> 
        <ns63:alternativeReference>Contents</ns63:alternativeReference> 
        <ns63:description>Business Personal Property</ns63:description> 
        </ns63:propertyDamages> 
       </ns48:property> 
      </ns48:contactInfo> 
     </newClaim> 
     </recordClaim> 
    </soapenv:Body> 
</soapenv:Envelope> 
+0

這是一個XML,它有許多命名空間 – Shrivallabh

+0

你的問題到底是什麼?爲什麼你需要製作這樣荒謬的XML? –

+0

我需要創建這個巨大的XML Individual這種命名空間如何創建? – Shrivallabh

回答

1

嗯,我不會去嘗試重現您的龐大的例子(這甚至不是有效的,因爲命名空間的別名如ns1不會在你出什麼)宣佈,但作爲一個較短的抽樣:

using System; 
using System.Xml.Linq; 

class Test 
{ 
    static void Main() 
    { 
     XNamespace foo = "http://foo.com/foo"; 
     XNamespace bar = "http://bar.com/baz"; 
     XNamespace baz = "http://baz.com/baz"; 

     XElement root = new XElement("root", 
      new XAttribute(XNamespace.Xmlns + "foo", foo.ToString()), 
      new XAttribute(XNamespace.Xmlns + "baz", bar.ToString()), 
      new XAttribute(XNamespace.Xmlns + "bar", baz.ToString()), 
      new XElement(foo + "a", 
       "Some text", 
       new XElement(bar + "b", 
        new XElement(baz + "c", "Deep element text")))); 

     Console.WriteLine(root); 
    } 
} 

結果(用手縮進):

<root xmlns:foo="http://foo.com/foo" 
     xmlns:baz="http://bar.com/baz" 
     xmlns:bar="http://baz.com/baz"> 
    <foo:a>Some text 
    <baz:b> 
     <bar:c>Deep element text</bar:c> 
    </baz:b> 
    </foo:a> 
</root> 
+0

謝謝,我會嘗試這個 – Shrivallabh

+0

uswshr50 ns1:我們有像我一樣的定義如上所述 – Shrivallabh

+0

@ user980408:好的 - 但看看你實際發佈的內容。它結束了元素中間。再次,我認爲你沒有發佈一個非常明確的例子。現在,我的解決方案不適合你嗎? –

相關問題