Re: XML Paths in Programming Languages

A clean way of approaching this would be to use variables in the XPath and pass in a set of variable bindings when you use the XPath, but I don’t know any API that actually does this.

Well, there’s always printf. In Java:

String xpath = "/cheese[@strength='%s']";
List<Element> smellyCheeses = doc.selectNodes(String.format(xpath, "smelly"));

Reply

The content of this field is kept private and will not be shown publicly.