我正在尝试使用XPATH表达式创建XML输入的规范形式,但是我不确定是否可以从文档中接收正确的输出。
我目前正在使用这个表达式,但我希望能够使用显示的第二个表达式,但是这不会返回任何结果。
我添加了这个命名空间,否则顶部也不起作用
xmlnsManager.AddNamespace("x", "http://www.mytest.uk/tester");
当前 XPATH -
x:testApplications/descendant-or-self::node()|//x:testApplications//@*
预期的 XPATH -
/testApplicationsBatch/testApplications|/testApplicaitonsBatch/testApplications//*
在 XPathVisualizer 中,预期路径为我提供了正确的输出,但在 .NET 中却没有。
XML 文档
<testApplicationsBatch xmlns="http://www.mytest.uk/tester" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mytest.uk/test testApplications.xsd">
<testMessageHeader>
<MessageID>00000020</MessageID>
<RegisteredBody>20130900006</RegisteredBody>
<Timestamp>2013-06-21T11:34:02</Timestamp>
<MessageCheck>8iOc6vuolwy1pFlfaSJcLZKPSruLlhYuXeTw1hCRAYi9N3MynGveElyECPyZUOBJ</MessageCheck>
</testMessageHeader>
<testApplications>
<testApplication>
<ApplicantDetails>
<Title>DR</Title>
<Forename>REJECT</Forename>
<Middlenames>
<Middlename>INTEGRITY</Middlename>
</Middlenames>
<PresentSurname>VALIDATIONTESTCASETWELVE</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>10 LODGE COURT</AddressLine1>
<AddressTown>STAINING</AddressTown>
<AddressCounty>LANCASHIRE</AddressCounty>
<Postcode>FY3 0EJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2003-07</ResidentFromGyearMonth>
</CurrentAddress>
<DateOfBirth>1977-01-01</DateOfBirth>
<Gender>male</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthTown>BLACKPOOL</BirthTown>
<BirthCounty>LANCASHIRE</BirthCounty>
<BirthCountry>GB</BirthCountry>
<BirthNationality>BRITISH</BirthNationality>
<ContactNumber>01253 897888</ContactNumber>
<UnspentConvictions>n</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>HEAD TEACHER</PositionAppliedFor>
<OrganisationName>HODGSON HIGH SCHOOL</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>D00000128</RBApplicationReference>
<RBNumber>20130900006</RBNumber>
<CSigNumber>20130900021</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>
</testApplicationsBatch>
返回的规范文件
<testApplications xmlns="http://www.mytest.uk/tester" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testApplication>
<ApplicantDetails>
<Title>MRS</Title>
<Forename>A'BCD THISISTEST CASEONEFORENAME</Forename>
<Middlenames>
<Middlename>MIDDLENAMEOFTESTCASEONE</Middlename>
</Middlenames>
<PresentSurname>ABCDEFTHISISTESTCASEONESURNAME</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>28 BROCKLEWOOD'S AVENUE</AddressLine1>
<AddressLine2>NEAR/HIGHCROSS-(PUB)</AddressLine2>
<AddressTown>POULTON-LE-FYLDE</AddressTown>
<AddressCounty>LANCASHIRE-TEST-COUNTY</AddressCounty>
<Postcode>FY6 7SJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2013-07</ResidentFromGyearMonth>
</CurrentAddress>
<PreviousAddress>
<Address>
<AddressLine1>1(FLAT2) CUMBERLAND HOUSE</AddressLine1>
<AddressLine2>A'B-C THISISTESTCASEONEADDRESSLINETWO</AddressLine2>
<AddressTown>ABERYSTH-TOWN</AddressTown>
<AddressCounty>G</AddressCounty>
<Postcode>L2 0QN</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentDates>
<ResidentFromGyearMonth>1997-01</ResidentFromGyearMonth>
<ResidentToGyearMonth>2013-07</ResidentToGyearMonth>
</ResidentDates>
</PreviousAddress>
<DateOfBirth>1977-01-13</DateOfBirth>
<Gender>female</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthSurname>A'B-CBIRTHSURNAME</BirthSurname>
<BirthSurnameUntil>2000</BirthSurnameUntil>
<OtherSurnames>
<OtherSurname>
<Name>OTHER SURNAME NAME</Name>
<UsedFrom>2000</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherSurname>
</OtherSurnames>
<OtherForenames>
<OtherForename>
<Name>OTHERFORENAMENAMETESTONE</Name>
<UsedFrom>1977</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherForename>
</OtherForenames>
<BirthTown>ASHTON-UNDER-LYME</BirthTown>
<BirthCounty>/1-'&COUNTYTESTONE</BirthCounty>
<BirthCountry>WS</BirthCountry>
<BirthNationality>GERMAN/-0'FRENCH</BirthNationality>
<ContactNumber>01253 897888/EXT - 1234</ContactNumber>
<UnspentConvictions>y</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
<PassportDetails>
<PassportNumber>12345678912</PassportNumber>
<PassportDob>1977-01-13</PassportDob>
<PassportNationality>BRITISH</PassportNationality>
<PassportIssueDate>2001-01-13</PassportIssueDate>
</PassportDetails>
<DriverLicenceDetails>
<DriverLicenceNumber>ABCDE 701017 AB1CS</DriverLicenceNumber>
<DriverLicenceDOB>1977-01-13</DriverLicenceDOB>
<DriverLicenceType>paper</DriverLicenceType>
<DriverLicenceValidFrom>2003-01-02</DriverLicenceValidFrom>
<DriverLicenceIssueCountry>IO</DriverLicenceIssueCountry>
</DriverLicenceDetails>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>CARETAKER'S ASSISTANT</PositionAppliedFor>
<OrganisationName>BIDE-A-WEE REST HOME'S/(ELDERLY&INFIRM)</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>ARM16</RBApplicationReference>
<RBNumber>20130800000</RBNumber>
<CSigNumber>20130800025</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>