I have the following XPath line
"(//DEAL_SETS/DEAL_SET/DEALS/DEAL/PARTIES/PARTY[ROLES/ROLE/
ROLE_DETAIL/PartyRoleType='Borrower'])
[(ROLES/PARTY_ROLE_IDENTIFIERS/PARTY_ROLE_IDENTIFIER/
PartyRoleIdentifier='1' or position() = 1)]/ROLES/ROLE/BORROWER/
RESIDENCES/RESIDENCE/ADDRESS/PostalCode[../../RESIDENCE_DETAIL/
BorrowerResidencyType='Current']"
which works when I put it in Altova XML Spy and gives me the result.
But when I use it directly, since it does Xelement.XPathSelectElement(XPath), it does not work, but it works Xelement.XPathSelectElement(collective, nameSpaceManager)where the collective is the namesspace prefix (for example, named "ns") plus my XPath line.
But the problem is that I need to change the XPath string to something like this
"(//ns:DEAL_SETS/ns:DEAL_SET/ns:DEALS/ns:DEAL/ns:PARTIES/ns:PARTY[ns:ROLES/
ns:ROLE/ns:ROLE_DETAIL/ns:PartyRoleType='Borrower'])[(ns:ROLES/
ns:PARTY_ROLE_IDENTIFIERS/ns:PARTY_ROLE_IDENTIFIER/
ns:PartyRoleIdentifier='1' or position() = 1)]/ns:ROLES/
ns:ROLE/ns:BORROWER/ns:RESIDENCES/ns:RESIDENCE/
ns:ADDRESS/ns:PostalCode[../../ns:RESIDENCE_DETAIL/
ns:BorrowerResidencyType='Current']"
Is there any way to avoid placing the namespace ( ns:) prefix on each node.
, xml, Party , PartyRoleType , , .. partyroleidentifier , , 2 , 1 2
<?xml version="1.0" encoding="utf-8"?>
<MESSAGE xmlns="http://www.example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xxxxReferenceModelIdentifier="3.0.0.263.12" xsi:schemaLocation="http://www.example.org/schemas C:\Subversion\xxx_3_0.xsd">
<DEAL_SETS>
<DEAL_SET>
<DEALS>
<DEAL>
<PARTIES>
<PARTY>
<ROLES>
<ROLE>
<PARTY_ROLE_IDENTIFIERS>
<PARTY_ROLE_IDENTIFIER>
<PartyRoleIdentifier>1</PartyRoleIdentifier>
</PARTY_ROLE_IDENTIFIER>
</PARTY_ROLE_IDENTIIERS>
<BORROWER>
<RESIDENCES>
<RESIDENCE>
<ADDRESS>
<PostalCode>56236</PostalCode>
</ADDRESS>
</RESIDENCE>
</RESIDENCES>
</BORROWER>
<ROLE_DETAIL>
<PartyRoleType>Borrower</PartyRoleType>
</ROLE_DETAIL>
</ROLE>
</ROLES>
</PARTY>
</PARTIES>
</DEAL>
</DEALS>
</DEAL_SET>
</DEAL_SETS>
</MESSAGE>