postgres xpath all nodes and use function on few of them

aido

New Member
I have a problem with writing a function in postgresql that gets input with xml data, then gets all nodes and for nodes that ends with work 'key' calls a function.In example i have to do:\[code\]function readdata(data xml) RETURNS VOID AS $$INSERT INTO data_table SELECT FROM xpath('//text()',data)\[/code\]Some of xml is like:\[code\]< node1>sometext< /node1>< node2_key>anyvalue< /node2_key>< node3_key>integer< /node3_key>< node4>anyvalue< /node4>\[/code\]But i dont know how to call function like \[code\]check_val('node2',valueof node2_key )\[/code\] when selecting from data parameter.What im trying to achive is: that in my SELECT in myfunction it gives me value of nodes when they don't end up with word 'key',and for nodes that ends with it gives me result of check_val function.Is there a way to do it with postgresql 9.1?I would be grateful with any example of code.
 
Back
Top