Sample Header Ad - 728x90

Extracting XML forming a resultset like format

0 votes
0 answers
140 views
I've encountered a case wherein I need to extract values from xml however, the tags are missing. To elaborate, I've manually finger-counted around 5 of the same elements however, one sibling node(bigger brother) doesn't have the same element as the other bigger brothers do. To put in example, please see xml below: (I used this previously, but I'll try to use this as an example) 8 so there's **** (big brother) where there'll be siblings (i'm looking for these elements). Now, when I extract them using xmllint with xpath, only those siblings that are present get extracted. The xml code might be a bad example but this is the format of what I'd like to achieve. On the left column, it's the big brother node, the right one is the sibling nodes DTS:CreationName="OLEDB" {A32A68DF-3D53-4057-AF80-1B8D524F82BC} DTS:CreationName="Excel" {A32A68DF-3D53-4057-AF80-1B8D524F82BC} DTS:CreationName="..." DTS:CreationName="blah blah" Is there a way to write the xmllint xpath code to 1. Create the same format as above? Just like database result set. 2. Add an extra character in between brother and sibling nodes so I can pick it up using awkie DTS:CreationName="OLEDB"%{A32A68DF-3D53-4057-AF80-1B8D524F82BC} 3. Instead of showing blank, just put NULL or any character that will alert me that the siblings are not present 4. Put the same brother node side by side if there is more than 1 sibling ie. big brother1%sibling1 big brother1%sibling2 This will really help . Looking forward to learning more of xmllint!
Asked by Kelvin (3 rep)
Feb 21, 2020, 02:48 AM
Last activity: Feb 21, 2020, 08:28 PM