我有下面的数据,我试图选择除RejectedRecords及其所有子节点之外的所有节点. ?xml version="1.0" encoding="UTF-8"?inmsg BPDATA DATE_TIME10072014084945/DATE_TIME /BPDATA Orders Rejected RejectedRecords RecordNumber1/Reco
<?xml version="1.0" encoding="UTF-8"?> <inmsg> <BPDATA> <DATE_TIME>10072014084945</DATE_TIME> </BPDATA> <Orders> <Rejected> <RejectedRecords> <RecordNumber>1</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <RejectedRecords> <RecordNumber>2</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <FileName>Foo1.txt</FileName> <MessageType>Rejected</MessageType> <RecordCount>2</RecordCount> <TotalAmount>1050.01</TotalAmount> </Rejected> <Unrestricted> <FileName>Foo2.txt</FileName> <MessageType>UnrestrictedState</MessageType> <RecordCount>2</RecordCount> <TotalAmount>100.10</TotalAmount> </Unrestricted> </Orders> <PrimaryDocument SCIObjectID="6442821469081a3a3node1"/> </inmsg>
我已经尝试过诸如此类的一些陈述
//*/node()[not(parent::RejectedRecords) and not(self::RejectedRecords) and not(self::RecordNumber) and not(self::RecordError)] //*[not(parent::RejectedRecords) and not(self::RejectedRecords)] //*[not(descendant-or-self::RejectedRecords)]
无论我使用什么,我仍然得到RejectedRecords节点及其子节点,因为它是与Rejected节点一起进入的.我究竟做错了什么?
此表达式选择所有节点,但不在结果集中包含任何RejectedRecords或具有RejectedRecords作为祖先的节点://*[not(descendant::RejectedRecords) and not(ancestor-or-self::RejectedRecords)]
以下是XPath Tester中结果的链接