HighTechTalks DotNet Forums  

Looping through IHTMLAttributeCollection in J#.

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss Looping through IHTMLAttributeCollection in J#. in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Bob
 
Posts: n/a

Default Looping through IHTMLAttributeCollection in J#. - 08-24-2004 , 10:43 AM






How can I loop through the IHTMLAttributeCollection in J#.
In C#, I can do it as follows:

IHTMLAttributeCollection myAttrColl =
(IHTMLAttributeCollection) myNode. attributes;
IHTMLDOMAttribute myAttr;

foreach myAttr in myAttrColl
{
if (myAttr.specified) //do something
}

But in J#, there is no foreach loop. Using for loop, I
tried the following:

for (int i=0; i < MyAttrColl.get_length(); i++)
{
myAttr = (IHTMLDOMAttribute) oAttrColl.item(i);
//now do something
}

But the syntax for item method is IHTMLDOMAttribute.item
(ref Object name). Hence, I get an error saying: method
IHTMLDOMAttribute.item(int i) not found.

Can someone please help?

Thanks,
Bob


Reply With Quote
  #2  
Old   
Bruno Jouhier [MVP]
 
Posts: n/a

Default Re: Looping through IHTMLAttributeCollection in J#. - 08-25-2004 , 12:56 PM






Did you try get_Item(i) ?

Bruno.

"Bob" <anonymous (AT) discussions (DOT) microsoft.com> a écrit dans le message de news:
513801c489e8$c6eee720$a301280a (AT) phx (DOT) gbl...
Quote:
How can I loop through the IHTMLAttributeCollection in J#.
In C#, I can do it as follows:

IHTMLAttributeCollection myAttrColl =
(IHTMLAttributeCollection) myNode. attributes;
IHTMLDOMAttribute myAttr;

foreach myAttr in myAttrColl
{
if (myAttr.specified) //do something
}

But in J#, there is no foreach loop. Using for loop, I
tried the following:

for (int i=0; i < MyAttrColl.get_length(); i++)
{
myAttr = (IHTMLDOMAttribute) oAttrColl.item(i);
//now do something
}

But the syntax for item method is IHTMLDOMAttribute.item
(ref Object name). Hence, I get an error saying: method
IHTMLDOMAttribute.item(int i) not found.

Can someone please help?

Thanks,
Bob




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Looping through IHTMLAttributeCollection in J#. - 08-31-2004 , 03:33 AM



The loop needs to change to

1. for (int i = 0; i < myAttrColl.get_length(); i++)
2. {
3. System.Object o = (System.Int32)i;
4. myAttr = (IHTMLDOMAttribute)myAttrColl.item(o);
5. //now do something
6. }

Notice that you cannot directly do the cast "System.Object o =
(System.Object)i", you first need to cast the primitive type 'int' to a
System.Int32 and then to System.Object.

Thanks,
Diganta Roy
Microsoft Visual J# .NET team

--------------------
Quote:
From: "Bruno Jouhier [MVP]" <bjouhier (AT) club-internet (DOT) fr
References: <513801c489e8$c6eee720$a301280a (AT) phx (DOT) gbl
Subject: Re: Looping through IHTMLAttributeCollection in J#.
Date: Wed, 25 Aug 2004 18:56:45 +0200
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <eqGHDSsiEHA.3664 (AT) TK2MSFTNGP12 (DOT) phx.gbl
Newsgroups: microsoft.public.dotnet.vjsharp
NNTP-Posting-Host: l06v-13-117.d2.club-internet.fr 62.34.190.117
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP12
.phx.gbl
Quote:
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.vjsharp:6422
X-Tomcat-NG: microsoft.public.dotnet.vjsharp

Did you try get_Item(i) ?

Bruno.

"Bob" <anonymous (AT) discussions (DOT) microsoft.com> a écrit dans le message de
news:
513801c489e8$c6eee720$a301280a (AT) phx (DOT) gbl...
How can I loop through the IHTMLAttributeCollection in J#.
In C#, I can do it as follows:

IHTMLAttributeCollection myAttrColl =
(IHTMLAttributeCollection) myNode. attributes;
IHTMLDOMAttribute myAttr;

foreach myAttr in myAttrColl
{
if (myAttr.specified) //do something
}

But in J#, there is no foreach loop. Using for loop, I
tried the following:

for (int i=0; i < MyAttrColl.get_length(); i++)
{
myAttr = (IHTMLDOMAttribute) oAttrColl.item(i);
//now do something
}

But the syntax for item method is IHTMLDOMAttribute.item
(ref Object name). Hence, I get an error saying: method
IHTMLDOMAttribute.item(int i) not found.

Can someone please help?

Thanks,
Bob






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.