From gdh1@osi.com Sat Jan 20 00:47:53 2001 Return-Path: Mailing-List: contact general-help@xml.apache.org; run by ezmlm Delivered-To: mailing list general@xml.apache.org Received: (qmail 54151 invoked from network); 20 Jan 2001 00:47:53 -0000 Received: from msgbas1x.cos.agilent.com (HELO msgbas1.cos.agilent.com) (192.6.9.33) by h31.sny.collab.net with SMTP; 20 Jan 2001 00:47:53 -0000 Received: from msgrel1.spk.agilent.com (msgrel1a.spk.agilent.com [130.29.176.117]) by msgbas1.cos.agilent.com (Postfix) with ESMTP id 123F8669 for ; Fri, 19 Jan 2001 17:48:00 -0700 (MST) Received: from osi.osi.com (unknown [198.137.135.99]) by msgrel1.spk.agilent.com (Postfix) with SMTP id 077C7AC0C for ; Fri, 19 Jan 2001 16:47:59 -0800 (PST) Received: from gdh1pc (gdh1pc [172.18.20.157]) by osi.osi.com (8.10.0/8.10.0) with SMTP id f0K0lqo19894 for ; Fri, 19 Jan 2001 16:47:52 -0800 (PST) Message-ID: <010001c0827a$9e2d16f0$9d1412ac@gdh1pc> From: "Gerry Haustein" To: Subject: how to quickly find an element (by attribute) in a DOM? any hints appeciated Date: Fri, 19 Jan 2001 16:47:50 -0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00FD_01C08237.8F4638D0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.3018.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N ------=_NextPart_000_00FD_01C08237.8F4638D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Anyone know how to do this? Given an element name, an attribute name and optionally an attribute = value: what is the best way to quickly find that element in the DOM? We have tryed getElementsByTagName (then searched the resulting list for = attributes) but that turns out to be too slow. Next we tryed using the special "ID" thing that can be used in DTDs, but = xerces then failed to load the document. Our XML/DTD loads okay unless = we try to specify ID in the DTD (as documented in our Wrox book). thanks for any help, Gerry -------------------------------------------------------------------------= ------- ]> IDEAS Debug Information IDEAS Debug Info ------=_NextPart_000_00FD_01C08237.8F4638D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Anyone know how to do = this?
 
Given an element name,=20 an attribute name and optionally an attribute value: what is the best way to = quickly find=20 that element in the DOM?
 
We have tryed getElementsByTagName (then searched the resulting = list for=20 attributes) but that turns out to be too slow.
 
Next we tryed using the special = "ID" thing that can be used in DTDs, but xerces = then=20 failed to load the document. Our XML/DTD loads okay unless we try to = specify=20 ID in the DTD (as documented in our Wrox=20 book).
 
thanks for any help,
Gerry
 

 
<?xml version=3D"1.0"?>
<!DOCTYPE debugDocument = [
<!ELEMENT=20 debugDocument (name,description,events)>
<!ELEMENT name=20 (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT = events=20 (event)*>
<!ELEMENT event (#PCDATA)>
<!ATTLIST event = id ID #REQUIRED>
<!ATTLIST event name CDATA = #REQUIRED>
<!ATTLIST event class CDATA = #REQUIRED>
<!ELEMENT=20 event (rules)>
<!ELEMENT rules (rule)*>
<!ELEMENT rule = (#PCDATA)>
<!ATTLIST rule op CDATA = #REQUIRED>
<!ATTLIST rule=20 op1 CDATA #REQUIRED>
<!ATTLIST rule op2 CDATA=20 #REQUIRED>
<!ATTLIST rule alert CDATA = #REQUIRED>
<!ATTLIST=20 rule event CDATA #REQUIRED>
<!ATTLIST rule lineNo CDATA=20 #REQUIRED>
<!ATTLIST rule relate CDATA=20 #REQUIRED>
]>
<debugDocument>
  =20 <name>IDEAS Debug Information</name>
  =20 <description>IDEAS Debug Info</description>
  =20 <events>
   <event id=3D"1" name=3D"" = class=3D"">
 =20 <rules>
  <rule op=3D"" op1=3D"" op2=3D"" alert=3D"" = event=3D"" lineNo=3D""=20 relate=3D"">
  </rule>
  = </rules>
  =20 </event>
  =20 </events>
</debugDocument>
------=_NextPart_000_00FD_01C08237.8F4638D0--