0

Within a c# project I'm sending a WebRequest to a php website, which takes the values and uses a select statement to query the DB and return an HTML page. Since there is only one value that comes back from that query, I need to assign this value to my c# code.

The source of the body-tag of the returned HTML-page (and with the StreamReader in my c#) looks like this:

<table border='1'>
    <tr><td>ValueINeed</td></tr>
</table>

How do I access the value inside this in order to assign it to a string in my c# code?

thank you.

2 Answers 2

1

If you are the author of the PHP code as well, I would suggest that you make another page that returns json or something instead, this way you would be able to avoid parsing HTML.

But if this really is what you are stuck with, I would suggest that you take a look at Html Agility Pack. Here is another quesiton here on StackOverflow that are about how to use the Html Agility Pack.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't have access to the php code so for now I will try to set up a regex. Help is still appreciated :-)
@TonyC, Do not use regex! Read this: stackoverflow.com/questions/1732348/…
0

If the result is always the same you could just split the string or use regex. If not you may use a html parser: http://htmlagilitypack.codeplex.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.