简体   繁体   中英

How to extract a list of string from xml file?

I have an xml file and an attribute "name" in some of the tags. If I give the correct xpath - is there a way to extract a list of strings, each element being one of the values of this attribute? (I do not need to get the entire list of DOM nodes...)

With XPath 2.0 or with XQuery you can write //@name/string() to get a sequence of string values of all name attributes in the document. With XPath 1.0 you can select the attribute nodes with //@name but then you need to use your host language (eg Java) to build a list of all the attribute values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM