Many programmer around there using RegEx. Is is powerful but complex.
It can archive what you want to get a string in anyway and
restriction.

For me, its very easy and recommended to use xpath but need more code
than RegEx.

First, you need to create xml object from the string that have html
tags. We can tread the html as xml since it is the exactly same
formatting. Then use xpath to enumerate to the tags hierarchy to get
the tag you need. Then simply get it InnerText to get the string.

If the tag is variable or else, you need to use your creativity on how
to get it. You can find the string based on tags hierarchy, tag name,
tag id, tag position on it siblings (like second child etc).

On May 5, 1:58 pm, rhitam <[email protected]> wrote:
> Hi all ,
>
> I am trying to generate an html file using c# . Now , the idea is to
> take an existing html , read another html file using the streamreader
> class, then read the content between the <body></body>
> in the second file , append this content to the existing body of the
> first html file .
>
> Now , the problem is , while reading the second file , it is possible
> that the body tag may have some attribute like some style definition
> or background color etc etc , and i do not know what that is. So what
> would be the best approach to solve something like this ?
>
> I already have a function  to get any string between two tags :
>
> http://www.mycsharpcorner.com/Post.aspx?postID=15
>
> But what if the tag itself is not constant?
>
> Any help appreciated,
>
> Regards,
> Rhitam

Reply via email to