If you want to test for existence of an attribute on an element:

if (elem.hasOwnProperty("@attr1") || elem.hasOwnProperty("@attr2")) {
    /* do something */
}

On 11/19/2014 12:50 PM, Alex Harui wrote:
Can attr1 and attr2 be empty strings?  Otherwise just test for that

          xml.SubProject.(@attr1!=“” && @attr2!=“”).@ID



On 11/19/14, 1:25 PM, "mark goldin" <[email protected]> wrote:

But I only want to check if both attr1 and attr1 exist. No value is known.

On Wed, Nov 19, 2014 at 3:15 PM, Alex Harui <[email protected]> wrote:

I’m not sure your example was valid.  If you instead had:

Var xml:XML = <Project Name="Project1">
   <Subproject Name=“Subproject1" ID="2293" attr1="1.00" attr2="2.00"/>
   <Subproject Name=“Subproject2" ID="2294" attr1="1.00" attr2=“3.00"/>
   <Subproject Name=“Subproject3" ID="2295" attr1=“2.00" attr2="2.00"/>
</Project>

Then I think you would use
         xml.SubProject.(@attr1==“1.00” && @attr2==“2.00”).@ID



On 11/19/14, 11:19 AM, "mark goldin" <[email protected]> wrote:

Let's say I have the following code:
<Project Name="Project1" ID="2293" attr1="1.00" attr2="2.00">
  <Subproject Name="Subproject1"/>
  <Subproject Name="Subproject2"/>
  <Subproject Name="Subproject3"/>
</Project>

I'd lit to find ID="2293" based on a fact that the element has both
attr1
and attr2.

Thanks for help.


Reply via email to