我要打印每个节点,子节点及其对应的值。
到目前为止,我只能打印子节点及其值,但是我也想打印其对应的父节点。
这是示例XML:
<?xml version="1.0" encoding="ISO-8859-1"?> -
<ServiceRequest version="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
<RequestHeader>
<ServiceName>ProcessAMLMessageService</ServiceName>
<ApplicationVersion>1.0</ApplicationVersion>
</RequestHeader>
-
<RequestBody>
-
<Arguments type="ContractApplicationAMLDetails">
-
<ContractApplicationAMLDetails>
<AMLDataLanguage>E</AMLDataLanguage>
-
<ContractDetails>
<ContractNumber>Contract-1</ContractNumber>
-
<SourceData>
<ThirdPartyInd>N</ThirdPartyInd>
-
<SourcesOfPayment>
-
<SourceOfPayment>
<SequenceNumber>1</SequenceNumber>
<PaymentSourceCode>PS-1</PaymentSourceCode>
</SourceOfPayment>
</SourcesOfPayment>
</SourceData>
</ContractDetails>
-
<Owners>
-
<Owner>
<PartyTypeCode>P</PartyTypeCode>
-
<Person>
<Surname>Amlcrsd</Surname>
<FirstName>Four</FirstName>
<DateOfBirth>1967-03-01</DateOfBirth>
<OccupationOrPrincipalBusiness>Pilot</OccupationOrPrincipalBusiness>
<AMLPEPInd>Y</AMLPEPInd>
-
<PEDPDetails>
-
<PEDP>
<Surname>ApplicantAPEDPu</Surname>
<FirstName>PEDPFourD</FirstName>
<CountryText>Canada</CountryText>
</PEDP>
-
<PEDP>
<Surname>ApplicantAPEDPv</Surname>
<FirstName>Four</FirstName>
<CountryText>Canada</CountryText>
</PEDP>
</PEDPDetails>
-
<HIODetails>
-
<HIO>
<Surname>ApplicantAHIOw</Surname>
<FirstName>HIOFourE</FirstName>
<CountryText>The United Arab Emirates</CountryText>
</HIO>
-
<HIO>
<Surname>ApplicantAHIOx</Surname>
<FirstName>HIOFourF</FirstName>
<CountryText>France</CountryText>
</HIO>
</HIODetails>
</Person>
-
<Address>
<AddressLine1>Adress line 1</AddressLine1>
<City>City 1</City>
<PostalCode>N2N 2N2</PostalCode>
<CountryCode>CA</CountryCode>
<CountryText>Canada</CountryText>
</Address>
</Owner>
</Owners>
</ContractApplicationAMLDetails>
</Arguments>
</RequestBody>
</ServiceRequest>
这是我要打印的结果:
Arguments.ContractApplicationAMLDetails.AMLDataLanguage =“ E” Arguments.ContractApplicationAMLDetails.ContractDetails.SourceData.ThirdPartyInd =“ N”
以此类推。
这不是确切的格式,但基本上我想打印每个父节点及其后续子节点及其值。