This README provides detailed documentation on using XPath expressions for navigating XML documents. It covers various axes relationships and dynamic element selection techniques using XPath.
- XPath Axes: Preceding and Following
- XPath Axes: Ancestor and Descendant Relationship
- XPath Axes: Parent and Child Relation
- Dynamic Elements: Elements with Dynamic Property-Values and/or Text
These XPath expressions allow traversal of nodes relative to a specified reference node (Node1) based on their positional relationship (preceding or following) within the document structure.
//Node1/preceding::*//Node1/preceding-sibling::*//Node1/following::*//Node1/following-sibling::*
These expressions enable traversal between ancestor and descendant nodes relative to the reference node (Node1) within the XML document hierarchy.
//Node1/ancestor::*//Node1/descendant::*
These expressions facilitate navigation between parent and child nodes relative to the specified reference node (Node1) within the XML document structure.
//Node1/child::*//Node1/parent::*
These expressions demonstrate dynamic element selection criteria utilizing various operators such as 'and', 'or', 'contains', and 'starts-with' to match elements based on their attributes and text content.
-
Using 'and' Operator
//TagName[@Att1='Value1' and @Att2='Value2']//TagName[@Att='Value' and Text()='Value']
-
Using 'or' Operator
//TagName[@Att1='Value1' or @Att2='Value2']//TagName[@Att='Value' or Text()='Value']
-
Using 'contains'
//TagName[contains(@Att,'Partial Value')]//TagName[contains(text(),'Partial Value')]
-
Using 'starts-with'
//TagName[starts-with(@Att,'Starting Value')]//TagName[starts-with(text(),'Starting Value')]
-
Hybrid
//TagName[contains(@Att1,'Partial Value') and starts-with(text(),'Starting Value')]//TagName[@Att1='Value' or starts-with(@Att2,'Starting Value')]//*[@Att='Value']
This documentation serves as a comprehensive reference for understanding and utilizing XPath expressions effectively in XML document processing. It can be used by developers, testers, and individuals working with XML documents to enhance their XPath querying skills.
Contributions to improve this documentation are welcome! If you have suggestions or find errors, please feel free to open an issue or create a pull request.
This documentation is licensed under the MIT License. Feel free to use, modify, and distribute it for any purpose.