简体   繁体   中英

Parse xPath like string and create xml document using jdom

I am trying to build some utility to create document model from a string like xpath:

setName(document,"college/class/student[14]@name","Rob"),

so, this function should create nodes and attributes in the document if it doesn't exist and move on if the node already exists.

I am failing to validate and implement the '[14]' part, ie creating 13 blank followed with adding attribute name with value of "Rob". As, there can also be cases of

setName(document,"university/college[2]/class[12]/student[14]@name","Rob")\

Thanks in Advance Tirthankar

You need a recursive parser that is able to handle the indexes.

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