using innertext 
Author Message
 using innertext

I can use

        html = WebBrowser2.Document.body.innerText

to get html content..........

how can I get html content excluding the content that related to
"<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 21 Oct 2003 12:03:22 GMT  
 using innertext
Hi,

you could try

html  = Replace(WebBrowser2.Document.body.innerText,
WebBrowser2.Document.body.text, "")

there may well be a more elegant way...

hope that helps

Adam Beaton


Quote:
> I can use

>         html = WebBrowser2.Document.body.innerText

> to get html content..........

> how can I get html content excluding the content that related to
> "<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 21 Oct 2003 16:13:02 GMT  
 using innertext
Sorry, my question may confuse you.

My question is : i want to get the innerText of one html excluding the
innertext between "<option></option>"

e.g.
.
.
.
<option>xxx</option>
.
.
.

<b>test</b>

I only want to get the word "test" but not the word "xxx" inside
"<option></option>"

Quote:

> Hi,

> you could try

> html  = Replace(WebBrowser2.Document.body.innerText,
> WebBrowser2.Document.body.text, "")

> there may well be a more elegant way...

> hope that helps

> Adam Beaton



> > I can use

> >         html = WebBrowser2.Document.body.innerText

> > to get html content..........

> > how can I get html content excluding the content that related to
> > "<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 21 Oct 2003 17:26:24 GMT  
 using innertext
Hi Roy,

sorry if I've misunderstood your question again, but if you are just trying
to get one distinct set of text, you can use a <div> or <span> tag with an
id, and use their innertext property.

e.g.
<FORM id="myForm" name="myForm" action="/whatever.html" method="post">
    <SELECT>
        <OPTION>some unwanted text</OPTION>
        <OPTION>some other unwanted text</OPTION>
    </SELECT>
    <SPAN id="mySpan" name="mySpan">
        <B>here is the text I want</B>
    </SPAN>
    <B>Some other stuff</B>
</FORM>
    <SCRIPT>
        function getMyText() {
            return myForm.mySpan.innerText;
        }
    </SCRIPT>

-----
getMyText will now return the text inside that <span>

if this is not what you mean again I apologise.

Adam


Quote:
> Sorry, my question may confuse you.

> My question is : i want to get the innerText of one html excluding the
> innertext between "<option></option>"

> e.g.
> .
> .
> .
> <option>xxx</option>
> .
> .
> .

> <b>test</b>

> I only want to get the word "test" but not the word "xxx" inside
> "<option></option>"


> > Hi,

> > you could try

> > html  = Replace(WebBrowser2.Document.body.innerText,
> > WebBrowser2.Document.body.text, "")

> > there may well be a more elegant way...

> > hope that helps

> > Adam Beaton



> > > I can use

> > >         html = WebBrowser2.Document.body.innerText

> > > to get html content..........

> > > how can I get html content excluding the content that related to
> > > "<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 21 Oct 2003 17:52:35 GMT  
 using innertext

But how can i write the code in VB ?

also, that mean there must be a "id" in the tag ? how about if the tag has no
id?

Quote:

> Hi Roy,

> sorry if I've misunderstood your question again, but if you are just trying
> to get one distinct set of text, you can use a <div> or <span> tag with an
> id, and use their innertext property.

> e.g.
> <FORM id="myForm" name="myForm" action="/whatever.html" method="post">
>     <SELECT>
>         <OPTION>some unwanted text</OPTION>
>         <OPTION>some other unwanted text</OPTION>
>     </SELECT>
>     <SPAN id="mySpan" name="mySpan">
>         <B>here is the text I want</B>
>     </SPAN>
>     <B>Some other stuff</B>
> </FORM>
>     <SCRIPT>
>         function getMyText() {
>             return myForm.mySpan.innerText;
>         }
>     </SCRIPT>

> -----
> getMyText will now return the text inside that <span>

> if this is not what you mean again I apologise.

> Adam



> > Sorry, my question may confuse you.

> > My question is : i want to get the innerText of one html excluding the
> > innertext between "<option></option>"

> > e.g.
> > .
> > .
> > .
> > <option>xxx</option>
> > .
> > .
> > .

> > <b>test</b>

> > I only want to get the word "test" but not the word "xxx" inside
> > "<option></option>"


> > > Hi,

> > > you could try

> > > html  = Replace(WebBrowser2.Document.body.innerText,
> > > WebBrowser2.Document.body.text, "")

> > > there may well be a more elegant way...

> > > hope that helps

> > > Adam Beaton



> > > > I can use

> > > >         html = WebBrowser2.Document.body.innerText

> > > > to get html content..........

> > > > how can I get html content excluding the content that related to
> > > > "<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 21 Oct 2003 18:21:36 GMT  
 using innertext
Hello Roy, You need to look at it from an OO perspective, Parsing HTML is a
pain (which is why so many browsers don't work so well) the Document object
actually gives you object hooks into every part of the document, the
<Select> Tag that will always be surrounding the <Options> tags in essance
becomes a collection of <Option>s therefore you can remove items from the
collection using the remove method that is exposed by the collection.
Look at this code I think it is what you need.

    Dim elem As HTMLObjectElement
    Dim i As Long
    WebBrowser1.navigate ("http://localhost/TestWeb/option.htm")
    'Loop through each component of the document
    For Each elem In WebBrowser1.document.All

        'if there is a select box, then remove all the children of the box
        If LCase(elem.tagName) = "select" Then
            Debug.Print (elem.innerHTML)
            Do Until elem.length = 0
                elem.Remove (i)
            Loop
            Debug.Print (elem.innerHTML)
        End If
    Next

Good luck, (it's really easy once you figure it out)

Lance Wynn


I can use

        html = WebBrowser2.Document.body.innerText

to get html content..........

how can I get html content excluding the content that related to
"<option>abc</option>" (i don't want to get "abc" , how can i do it??)



Tue, 28 Oct 2003 22:04:40 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Can't get innerText from TextArea

2. innertext and tables...

3. webbrowser1 and innertext taking previous page

4. innerText works but innerHTML causes an error w/ WebBrowser ctl and VB6

5. InnerText method strips white space from HTML!

6. Difference between InnerText And OuterText..

7. Using types in a different assembly given that the type may be used or not used

8. Using a main form to control the edit properties of a subform using VBA

9. Using a defined Variable to Update a Table using DoCmd.RunSQL

10. Using VBA to develop DBase file using Excel

11. Using NewMail events using .NET ?

12. Send/Receive using VB using View Control Object

 

 
Powered by phpBB® Forum Software