.net - Xml: best practice to create x-path with parameters -


what best practice create x-path parameters?

i have select xml node attribute has exact value, like:

xmlnode node = parentnode.selectsinglenode(   string.format("./field1/field2[@attributename='{0}']", valuerequired)); 

the host of xpath engine can create variables part of context. example of host, providing facility xslt.

in xslt 1 write:

field1/field2[@attributename=$valuerequired]" 

one way of creating xpath variables , functions in .net use xsltcontext class , methods resolvevariable() , resolvefunction()

another thing remember: never blindly insert user input "skeleton" of xpath expression. aware of possibility xpath injection.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -