Querying for an XML node based on a value of another node

(imported topic written by EdRedmond)

I am trying to query for an XML node based on a value in another node in the IIS applicationHost.config file.

For example, I am trying to query for the location node which matches a site name.

Specfically, I am looking at the followng node…

<system.applicationHost>

    <sites>

         <site name="DefaultWebSite">

by using the following relevance code…

child nodes whose (node name of it = “site”) of selects (“cionfiguration/system.applicationHost/sites”) of xml document of file “some XML file name”

now while stepping through each of these nodes, I want to look for the folloiwng node

<location path="DefaultWebSite">

see the name attrbiute in the site node above and the path attribute in the location node are the same.

Is anyone aware of how to accomplish this?

(imported comment written by jgstew)

a better example XML document would be helpful.

First, figure out the correct query to return “DefaultWebSite” from this:

<location path="DefaultWebSite">

Then getting the correct site node would be something like this:

child nodes whose (node name of it = “site” AND attribute “name” of it = ()) of selects (“cionfiguration/system.applicationHost/sites”) of xml document of file “some XML file name”

(imported comment written by EdRedmond)

Axctually I am enumerating through all of the site nodes iunder the sites node in the applicationHost file.

For example a part on my applicationHost.config file contains the following:

<system.applicationHost>

    <sites>

         <site name="DefaultWebSite">

            ...

        </site>

        <site name="site1">

            ...

        </site>

        <site name="site2">

            ....

        </site>

Now as I am enumerating through the sites (DefaultWebSite, site1 and site2) I may need to reference the corresponding location node which has a path name that equates to the site name (DefaultWebSite, site1 OR site2)

so my relevance code for getting all of the site names is:

(node value of attribute “name” of it) of child nodes whose (node name of it = “site”) of selects (“configuration/system.applicationHost/sites”) of xml document of
some XML file name

so how would I be able to reference the site name that i am currently on in order to get the correct location node because if I use the folloiwng

select (“configuration/location”) whose (node value of attribute “path” of it =
it
) … where the highlighted blue text would be the reference to the site name.

(imported comment written by jgstew)

Are you trying to get all location nodes, or a specific location node?

The only way I know how to do this is basically with single recursion. There is probably a better way, but the following should work:

selects (“configuration/location”) whose (((";" & it & “;”) of concatenation “;” of (node value of attribute “name” of it) of child nodes whose (node name of it = “site”) of selects (“configuration/system.applicationHost/sites”) of xml document of (some XML file name)) contains ((";" & it & “;”) of node value of attribute “path” of it)) of xml document of (some XML file name)

I’m cheating and using concat to convert from plural to singular, and this code is also not very efficient and will get slower exponentially based upon the number of location nodes. There is probably a better way to do this.

(imported comment written by EdRedmond)

Yes I am looking at a specific location node based especially if the site node does not contain information I am looking for. I know this isa little dificul to do, but only working with TEM relevance language for ~ 6 months I knew there are much wiser relevance gurus out there.

(imported comment written by Senthilnathan Manoharan)

Hello Ed

I am working on a similar problem and used your example as reference. I am trying to retrieve the physical path associated to all websites (refered by the attribute “physicalPath”). But I am unable to list them properly. This is the statement I am using.

(node value of attribute “physicalPath” of it) of child node of child node of child nodes whose (node name of it as lowercase = “site”) of selects (“configuration/system.applicationHost/sites”)
of xml document of file “applicationHost.config” of folder “inetsrv/config” of system x64 folder

I am getting this error message

Current Selection Evaluates To:

   E:\Public\Web\Wellpoint
   Error: Singular expression refers to non-unique object.

I tried changing singular/plural forms but to no use. I’ve also attached the xml file I am fighting with here.

I am stuck on this for 3 days now and Your advice is much appreciated.

Thanks

Senthil Nathan M

(imported comment written by jgstew)

Try This:

(node values of attributes “physicalPath” of it) of child nodes of child nodes of child nodes whose (node name of it as lowercase = “site”) of selects (“configuration/system.applicationHost/sites”)

of xml document of file “applicationHost.config” of folder “inetsrv/config” of system x64 folder

(imported comment written by Senthilnathan Manoharan)

Hello
James

Your solution worked perfectly.

Thank you very much.

Thanks

Senthil Nathan M