# How to reference fields outside an XML event?

**URL:** <https://discuss.elastic.co/t/how-to-reference-fields-outside-an-xml-event/81522>\
**Category:** Logstash\
**Created:** [April 6, 2017, 6:01pm UTC](https://discuss.elastic.co/t/how-to-reference-fields-outside-an-xml-event/81522 "2017-04-06T18:01:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chg](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@chg](https://discuss.elastic.co/u/chg)\
**Post date:** [April 6, 2017, 6:01pm UTC](https://discuss.elastic.co/t/how-to-reference-fields-outside-an-xml-event/81522/1 "2017-04-06T18:01:45Z")

</div>

Example XML:

```
<REPORT>
	<RESULTS>
		<EVENT_LIST>
			<EVENT>
				<ID>1</ID>
				<URLS>
					<URL>
						www.google.com
					</URL>
					<URL>
						www.elastic.co
					</URL>
				</URLS>
				...
			</EVENT>
			<EVENT>
				<ID>2</ID>
				<URLS>
					<URL>
						www.google.com
					</URL>
					<URL>
						www.elastic.co
					</URL>
				</URLS>
				...
			</EVENT>
		</EVENT_LIST>
	</RESULTS>
	<INFO>
		<INFO_LIST>
			<ID>
				<ID>1</ID>
				<CATEGORY>A</CATEGORY>
				<DESCRIPTION>This is id 1</DESCRIPTION>
			</ID>
			<ID>
				<ID>2</ID>
				<CATEGORY>B</CATEGORY>
				<DESCRIPTION>This is id 2</DESCRIPTION>
			</ID>
		</INFO_LIST>
	</INFO>
</REPORT>

```

I've been able to split each event and flatten and parse all the fields in each event using ruby. I would like to include all the fields in 'info' corresponding to the event's id.  
So the event would look like

"id" =\> "1"  
"url" =\> "[www.google.com](http://www.google.com), [www.elastic.co](http://www.elastic.co)"  
"category" =\> "A"  
"description" =\> "This is id 1"

I've tried setting xpath to "/REPORT/INFO/INFO\_LIST/ID" and referencing it in the ruby code, but get an undefined variable error. I've also tried adding a field to the xml filter, but with no sucess. Is there a way to reference fields outside of the current event?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 4, 2017, 6:01pm UTC](https://discuss.elastic.co/t/how-to-reference-fields-outside-an-xml-event/81522/2 "2017-05-04T18:01:45Z")

</div>

Closed on May 4, 2017, 6:01pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
