# getComponent vs getComponentForPath

**URL:** <https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875>\
**Category:** Ignition\
**Created:** [July 24, 2012, 7:32pm UTC](https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875 "2012-07-24T19:32:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [July 24, 2012, 7:32pm UTC](https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875/1 "2012-07-24T19:32:23Z")

</div>

What’s the difference between getComponent and getComponentForPath?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 24, 2012, 7:41pm UTC](https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875/2 "2012-07-24T19:41:22Z")

</div>

The function getComponent gets a component inside of the container with a specific name. The component has to be directly inside of the container meaning 1 level deep. The function getComponentForPath allows you to find a component inside of a container based on a path not just a name. The component can be many levels deep.

---

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [July 24, 2012, 7:57pm UTC](https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875/3 "2012-07-24T19:57:31Z")

</div>

So either code gets you to the same component

[code]myWindow.rootContainer.getComponent(“myButton”)

myWindow.getComponentForPath(“Root Container.myButton”)[/code]

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 24, 2012, 8:01pm UTC](https://forum.inductiveautomation.com/t/getcomponent-vs-getcomponentforpath/4875/4 "2012-07-24T20:01:00Z")

</div>

Correct
