Please, help me: i want to build xml with all merge fields in document in parent-child view. For this i need to retrieve all merge fields between one pair TableStart and TableEnd as childs of the tag
How may i do this? Is any functins or way for this?
Thanks for your inquiry. Unfortunately, there is no direct way to populate nested regions using Aspose.Words. It is possible, however, to generate the above reports by performing mail merge several times and building up a resulting document from several documents or fragments. The Product Catalog and Sales Invoice samples in the demo project supplied with Aspose.Words demonstrate the suggested techniques.
Hope this helps.
Unfortunately it a bit another:(
Could you please provide me your template, sample data and desired output. I will investigate the issue and try to help you to find a solution.
I am sorry, maybe, I has not clearly asked a question, but you have not understood me.
I have a word file with merge fields. Example:
- Fields “First Name”, “Last Name”
- small table with next filelds: “TableStart:Orders” and “TableEnd:Orders” and 2 columns with 2 merge fields “Order Number” and “Order Sum”
- just flow text with filelds: “TableStart:Product” and
“TableEnd:Product” and 2 merge fields between them “Product Number” and “Product Sum”.
I want to receive (created instance of Document class from my word file by aspose.word: Document doc = new Document(
System.IO.Path.Combine(DocPath, “myDoc.doc”)) a xml-structure of all merge fields in douments in next view:
Please, how can i do this?
Thanks for your request. I think, you can try using code like the following:
// Open document
Document doc = new Document(@"Test001\in.doc");
// Get list of mergefields in the document
string names = doc.MailMerge.GetFieldNames();
// Create XML writer
using (XmlTextWriter xmlWriter = new XmlTextWriter(@"Test001\out.xml", Encoding.UTF8))
xmlWriter.Formatting = Formatting.Indented;
// Loop throught all mergefields and build structure of mergefields.
foreach (string name in names)
xmlWriter.WriteAttributeString("name", name.Substring(name.IndexOf(":") + 1));
else if (name.ToLower().StartsWith("tableend"))
Sample documents are attached. I hope this could help you.
Thank you very much This is i need:)For my purposes as I thought there are 2 variants of the decision:
- That you have offered - but I have not been assured up to the end, that fields inside of a file will always settle down in the necessary order. Especially, if in following versions will get support nested tables
- transform doc file into xml and go on xml structure in searches of parent-child relations between merge fields
Thank you once again - your answer has dispelled all my doubts
The first approach will work for you. It gives the fields in the order in which they appear in the document, including possible repetitions. By the way, we don’t plan to implement nested mail merge in considerable future.
The second approach will lead to expensive computations if you think about building full document tree in XML and searching among its nodes. You can also convert your DOC file to WordprocessingML format since it is XML-based and contains all information from the source. But I don’t think it’s a good idea.
The issues you have found earlier (filed as 39) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.