Free Support Forum - aspose.com

Can i save a node in db?

Hi every one!

Can i save a node in db?

Hi,


Thanks for your inquiry.

Storing a single node inside database might well not be a good idea; for example, you cannot have a valid Cell or Row on it’s own, a Cell will always be a child of Row and a Row will always be child of a Table. Therefore it’s difficult to try extract a Cell node (with all it’s formatting) only for storage in a database. Furthermore, in order to preserve absolutely all formatting for a Cell during retrieving from database, you will need to store the node in the original format. In this case, storing the entire table from the document in the database might do the trick.

If you are looking for a way to save certain nodes with their formatting to a database then there is a way to achieve this. Please take a look at the documentation here. It shows how you can save a document to a database and then retrieve it. In your situation where you want to save just specific nodes then you can use the same method as above, importing specific nodes to a tempdoc and then saving the tempdoc to a database.

I hope, this helps.

Best regards,

Thank you for your answer…

Are you say that, saving a node (i.e. a run) with all formatting is not logical?

I think saving a node with all formatting get less size to saving a document that contains a node.

Hi,


Thanks for your inquiry. Yes, saving an individual node in database occupies lesser space as compared to saving a Document that contains a node. However, you should note that saving an individual node in Database is not logical sometimes; for example, a complete field in a Microsoft Word document is a complex structure consisting of a field start character, field code, field separator character, field result and field end character and when you save an individual FieldStart node in DB, it makes less sense.

If we can help you with anything else, please feel free to ask.

Best regards,

Thank you.


No, I want to save a simple run, paragraph or a table with formatting in db,
so, I want to know is it possible?

Hi,


Thanks for your inquiry and sorry for the delayed response. In your case, the best way you can achieve this is by exporting the content of the Node into an Html string. For example, you can export the Run node to an Html string by using the following code and then save this Html string inside your database. However, you should note that when you export to Html, some formatting may get lost.

string runHtml = run.ToString(SaveFormat.Html);

Best regards,

Thank you …