I am learning azure functions as a part of it, i want to merge two different xml files of same xml structures in to a single xml file. Can some one please help me how to do that using azure functions ?
While merging the xml through async method, i am unable to open the xmldocument using XmlDocument.Open as there is no definition Open for XmlDocument. How do we open the xmldocument data ?
This is my code and i got stuck at while open the xmldocument through memorystream
private async Task<IList> MergeFileAsync(CloudBlobContainer container, string[] blobFiles)
{
XmlDocument outputDocument = new XmlDocument();
foreach(String fileblob in blobFiles)
{
string file = $"" + blobFiles;
CloudBlockBlob blockBlob = container.GetBlockBlobReference(file);
using(var memoryStream = new MemoryStream())
{
await blockBlob.DownloadToStreamAsync(memoryStream);
string contents = blockBlob.DownloadTextAsync().Result;
//stuck here
var inputDocument = XmlDocument.Open(memoryStream, XmlDocument.Import);
}
}
}
2
Answers
I would suggest you read the blob files and add the blob content to the single separate file. If you want to combine the excel file, we have two approaches to achieve. Either you can use
Microsoft.Office.Interop.Excel
package and usingFile Stream
.Here I have collected the file from blob and adding content of the file in separate file.
Using Microsoft.Office.Interop.Excel :
Refer to C# Corner article for
using stream
to add content to excel file.As you have already got xmldocument content, you have to instantiate xmldocument with content.