7 Replies Latest reply on Jul 24, 2015 5:02 PM by Pratik

    Accessing AFElement directly with its Path

    Pratik

      Is there a way to access a particular AFElement in the hierarchy, if we know its location path? like if I know the whole path in the hierarchy starting from the root, the how can I access that AFElement? Basically I don't want to loop through the hierarchy to obtain AFElement Object, Because I have its location path/detail.

        • Re: Accessing AFElement directly with its Path
          Pratik

          If possible then Anyone can help me how can I use findElementsByPath() ?

          I tried with FindElement() but it doesn't search if I use whole Path in search criteria.

            • Re: Accessing AFElement directly with its Path
              bshang

              Here is a simple example:

               

                          AFKeyedResults<string, AFElement> results = AFElement.FindElementsByPath(new string[] { @"\\YourAFServer\Path\To\Element" }, null);
              
                          foreach (AFElement result in results)
                          {
                              Console.WriteLine("Element name: {0}", result.Name);
                              Console.ReadKey();
                          }
              

               

              Is there an error you are running into?

                • Re: Accessing AFElement directly with its Path
                  Pratik

                  Hi Barry,

                   

                  I tried with the solution that you gave, But its not working. I have below hierarchy. and wanted to access LR 29609

                   

                  I used below;

                  AFKeyedResults<string, AFElement> results = AFElement.FindElementsByPath(new string[] { @"\\PIUDNAFDEV01\EDPI_DEV\AOR8\FRESNO\AIRWAYS\Bank 1\CB 1101\LR 29609" }, null);

                   

                              foreach (AFElement result in results)

                              {

                                  Console.WriteLine("Element name: {0}", result.Name);

                                  Console.ReadKey();

                              }

                  What could be the issue? Results is null.