XPATH expression to parse a nested xml file


(Tarun Sant) #1

Following is the input xml I want to parse.

<robot>
	<suite>
		<some_data_1 attr1="value1">
		<some_data_2 attr2="value2">
	</suite>
	<status val="val1">
	<suite>
		<stat time_start=1449504352 time_end=1449504354>test_1</stat>
	</suite>
</robot>

From this input xml I want to get the "time_start" and "time_end" from the tag.

I have tried with using XPATH, but I am not able to get the data. I am able to get the data using XPATH, but "time_start" and "time_end" is not able to get.

Need some help in this regard.


(Magnus B├Ąck) #2

After fixing the XML syntax problems //robot/suite/stat/@time_start can be used to select one of the attributes. I didn't try it in Logstash but I'd be surprised if it didn't work there. If you still have problems please provide details.


(Tarun Sant) #3

Thanks a log for your reply.

XML I have provided is a custom one and with that I just wanted to show the structure of the nested xml file.
I have tried in the following format and I am able to extract data.
/robot//stat/@time_start


(system) #4