Hi i am working on a c# applcation
what it does basically is get specific tags and checks their contents.
My problem lies here, if one of the tags contents isnt correct i need to show the line of code where the tag resides in the html source code.
Can someone help please...

Recommended Answers

All 4 Replies

simple actually.
Assuming you are parsing the text file character by character, set a variable to zero first, and increment it whenever you hit a newline indicator.

Here is the C# code:

int errline = 0;
private void Parse(string html){
  int c;
  while(c < html.Length){
    if (html.SubString(c, 1) == Environment.NewLine){
      errLine++;
    }
  }
}

//On error:
MessageBox.Show("Error on Line " + errLine.ToString());

HTH.

woops, that variable needs to start at 1, so its

int errLine= 1;

what is the variable c???

that is the current position of the character you are reading in the string.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.