I have a question about htmlagilitypack.
How can I insert into specific line or lineposition (not node)? If I have HtmlParseError at line 100 (missing opening tag ), how can I insert this missing tag into that line.
In the general case, you can't.
You'll have to reload the file with a standard text stream (StreamReader say), and fix it directly in the raw text, using the line & column position.
Related
I want to write an image array to text file when i try the result is one column which contain all values.
Build up each line in the format you want, then write the whole line to file. There are suitable functions to help in the std.textio library.
I hope, there is a solving of my question. But I can't find it.
Problem: ajax return data with line break (\n). The data must be insert into textarea and will be update from ajax.
I can replace '\n' when reading data (myJsonData.replace.() ... etc). The main problem: how to ready data for textarea to display in correct format with line break?
just replace it to something revertable, like -=br=- and when insert to the textarea, replace back to \n
There is no problem with line breaks in textarea and you just can insert the data as is. But if you still have problems with special chars - you can encode your JSON data and decode it on insert.
I've searched online and on StackOverflow, but I can't seem to find the answer to my question, although some of them came very close.
I am programming for .Net in Delphi Prism. I have a RichTextBox on a WinForm and I need to insert a line of text at the top every time program does insert. So, I am doing the following and it runs upto the line and raises the following exception.
offending code:
RichTextBox1.Lines.SetValue(str,0);
Exception:
Index was outside the bounds of the array
I think, I think I know why it is raising the exception. It's because there are no lines inserted into RichTextBox. So, my program really can't insert any line of text. I need to really insert line of text at the top everytime my program inserts a new line of text.
If I do call RichTextBox1.AppendText(str);, then it works and inserts the str text without newline, but it appends at the end. I want it inserting text at the top every time.
How do you insert line of text into RichTextBox?
Thanks.
The Lines property of the textbox is simply an array of string. So you need to add one element, move all elements one index down and insert your new text at the first index.
Also the Text property of the textbox is a string. Strings in .NET are immutable, so you need to fully replace the value.
One approach would be like this:
RichTextBox1.Text := "YourNewText" + Environment.NewLine + RichTextBox1.Text;
I'm using VB6 and ADO together with the Microsoft Text Driver to import data from an ASCII file. The file is comma delimited but it also contains double quotation marks around text data fields. The fields are also fixed width.
I'm having a problem that the driver reads the columns incorrectly any time one of the rows contains a quotation mark double quotation inside the content. This happens inside the "part description" column which is the second column from the left. When this occurs, columns to the right are all Null value, which is not the case in the text file.
I think it would be better to use only the commas as delimiters. However, I believe that commas also occur in the "part description" column so this means I should really load the file as fixed width. I'm not aware that there is any way of doing this unless I can specify this in the schema.ini file.
Any ideas on how to resolve this?
Edit:
You are allowed to specify fixed width in your Schema.ini file. However, it appears to me that the commas and quotation marks that also exist as delimiters/qualifiers will prevent this from working properly. It looks like I may have to "manually" read the file in and write it back out in my own format before I load it using the MS Text driver. Still looking for other opinions.
I would try changing the Format value in the registry for the Jet text engine (if that's what you're using) at the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text. I think the default is CSVDelimited but you would change this to FixedLength. See http://msdn.microsoft.com/en-us/library/ms974559.aspx
It's probably worth adding that although you have a Schema.ini file for settings, on some options the registry overrules them anyway
Actually, looking at the link I supplied, it seems you have to use a schema.ini file for fixed-length files. Have you tried something like the following, which specifies the width?
[Test.txt]
Format=FixedLength
Col1=FirstName Text Width 7
Col2=LastName Text Width 10
Col3=ID Text Integer 3
I'm extra precautious with regional settings -- some users change default list separator. Usualy fix this with schema.ini like this:
[MyFile.csv]
Format=Delimited(,)
I need to add text before the last line in a text file in windows using command. Can any one please suggest a method?
Thanks in advance.
You can do it in 5 simple steps, and you can use any language of your choice or according to your other requirements ( like c, c++, java etc.)
Read Complete File
Extract Last line by looking for last newline
Store Last Line and erase it from file
Append New Text
Append last line which you deleted previously.
Don't forget to close your file.