I’m looking for something exactly like: XMLTABLE, http://www.ibm.com/developerworks/data/library/techarticle/dm-0708nicola/
Does something like this exist in PostgreSQL, or what would be closest?
Or another way, is there a Java library that can accomplish this?
EDIT:
Thanks to Erwin (the answer in his comment is almost precisely what I was looking for).
However, perhaps I could suggest an extension to this.
Consider, we have an xml document like:
<comments photo_id=“123”>
</comment>this is the first comment</comment>
</comment>this is the second comment</comment>
</comments>
While, this is a simple example, consider also that “comment”
could be quite sophisticated.
My question is now: using the XMLTable function (or Erwin’s implementation), we need to specify a path_to_data
i.e. in this case (/comment
).
However, if I want my return schema to be something like: [photo_id, comment_text]
.
There is no way to get data from the elements of the parent of the datanum.
Is it therefore possible to somehow modify your code to do this? My guess is having something more sophisticated than the xpath function, which essentially returns a subset of data by tracing to the parent.
For example:
<comments photo_id=“123”>
</comment>this is the first comment</comment>
</comments>
<comments photo_id=“123”>
</comment>this is the second comment</comment>
</comments>
In this case, we can access “/comments/@photo_id”
.