Find value

Hi,

is there any nice posibilities (e.g. public service) which can help me to get particular parameter value for specific parameter name .

For example, I’ve got list of document:

  • test (docTest)
    • name (parameterName)
      -value (parameterValue)

i need to get value for name : “surname”.

Thanks for all replies

A basic approach:

Loop over the document list
…Branch on doc/name
…surname: MAP (map doc/value to output)

thx ,

but I know this approach and i’m looking more sophisticated solution.
I quess there’s no better approach.

Pretty much any solution will boil down to looping and comparing.

Another possibility is to load the list of items into a hashmap. If you’re doing many lookups this might be worth the overhead.

dont want looping, do Xpath:

  1. Get xml node from the document:
  • pub.xml:documentToXMLString
  • pub.xml:xmlStringToXMLNode
  1. Do Xpath:
  • pub.xml:queryXMLNode, String Output named as vals, with variables query (use XQL):
    docTest/doc[name=“surname”]/value

struct doc:
docTest …IData
doc …IData
name …String
value …String
xpath2.jpg

Not sure but to my mind all these transformations documentToXMLString -> XmlStringToXMLNode -> queryXMLNode may result in a “high” ressource usage if you call them a lot (no ?)

You can use XPath in setValue, if the path to your field is fix. Unfortunately xpath in setValue does not evaluate conditions, if your path is flexible I only the possibilities already posted by Rob and Ayell. I used pub.xml:queryXMLNode some times myself, but that was mainly for smaller structures.

i agree with Reamon comments on this one.

PSUtilities has a service that may be what you’re looking for or it can at least get you going in the right direction so you can write your own generic Java service to do this:
ps.util.list:filterDocumentList

  • Percio