Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Xpath in c #

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use Xpath in c #, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

In c #, we often find and traverse nodes, which is the XPath syntax we can use. XPath syntax is very simple, but powerful enough. XPath can quickly locate nodes or attributes in Xml. It is also the basic knowledge of using xslt.

Example Xml:

100 this is a black cat 80 this is a white cat 80 this is a yellow cat 100 this is a black dog 80 this is a white dog 80 this is a yellow dog

The syntax of XPath:

1. Symbols in XPath

Symbol

Description

Example

Example illustration

/

Indicates that the selection starts from the root node

/ pets

Select the root node pets

Represents the spacer between a node and a child node

/ pets/dog

Select the dog node under the pets node

/ / xx

Means to look from the entire xml document, regardless of the current node location

/ / price

Select all price nodes in the document

.

A single English half-corner period indicates the selection of the current node

/ pets/.

Select the pets node

..

Double dots, indicating that the parent node is selected

/ pets/dog [0] /..

Represents the pets node, which is the parent of the first dog node

@ xx

Represents a selection attribute

/ / dog/@color

Represents a collection of color attributes for selecting all dog nodes

[.]

The square bracket indicates the selection condition, and the condition is in the bracket.

/ / dog [@ color='white']

All dog nodes whose color is white

/ / dog [/ price is greater than

> = greater than or equal to

< less than

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report