Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I m in urgent requirement to convert the SGML file in XML using code.Cant use any converter packs. What all I need for this? please reply if any body have worked on this or have any idea.
C#
protected void btUpload_Click(object sender, EventArgs e)
       {
           string fullFilePath = null;
           if (flImport.HasFile)
           {
               string fileName = string.Empty;
               string extension = string.Empty;
               string path = string.Empty;
               fileName = flImport.PostedFile.FileName;
               string flFilePath = Server.MapPath("Files/" + fileName);
               flImport.SaveAs(Server.MapPath("Files/" + fileName));
               fullFilePath = flFilePath;
               extension = Path.GetExtension(fileName);
               path = fileName;
               if (string.Equals(extension, ".Sgml") )
               {
                   ckContent.Text = ConvertSGMLToXml(fullFilePath );
               }
           }
       }


here i need to write a code for the function ConvertSGMLToHtml(fullFilePath )
Posted
Updated 2-Sep-14 21:48pm
v3
Comments
Richard MacCutchan 2-Sep-14 7:40am    
So what exactly is the problem?
Member 11017651 3-Sep-14 3:47am    
My requirement is to convert SGML to HTML . But i have codes to convert XML to html . So if i get codes to convert SGML to xml the other part i can do it. So i searched it like this way. i saw packs converting SGML to XML . But that is not my requirement. Forgive me for my ignorance in english language as well as in the programming. i think now you can understand my problem.
Richard MacCutchan 3-Sep-14 4:02am    
Yes, I already understood your problem. I just do not know what help you are expecting from here. If you cannot find a sample to convert SGML to HTML then you will need to write your own.
Member 11017651 3-Sep-14 4:11am    
Yes. I think So. But I just started learning things now. That's why i posted my problem here. Anyway thanks for the replies.
Member 11046425 11-Sep-15 2:42am    
Hi, i am new in code project, I need the same requirements right now. If you have any code for converting SGML to XML using C# in ASP.NET please Post here .It will help to me. thank you.

If you only want to view the contents of the file, you can use an embedded IE browser and set the document text to the file contents. This works for SGML, XML and HTML.

If you need special formatting of the file contents you can use XSLT to do the transform.
Unless you have a generic file structure, you will have to create an XSLT file for each structure.
It is a bit of a threashold to learn XSLT, but in the end it saves a lot of time in my experience.
XSLT Tutorial[^]


Another option is to parse the document yourself, but that is a LOT of work especially if you have different file structures.
 
Share this answer
 
If any one has this answer please help. I am also in same requirement.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900