Results 1 to 3 of 3

Thread: Possible to define HMTL file as table structure with content separate?

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    1,891
    Thanks
    218
    Thanked
    61 times in 53 posts
    • jonathan_phang's system
      • Motherboard:
      • Asus Rampage III Extreme
      • CPU:
      • i7 930 @ 4.2 ghz (200x21)
      • Memory:
      • 12GB Corsair XMS3 1600
      • Storage:
      • Crucial M4 128GB SSD + Misc Data Drive
      • Graphics card(s):
      • EVGA GTX 1080 FTW
      • PSU:
      • Corsair HX850 Modular
      • Case:
      • Antec 300
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • Asus PB278Q (27" 2560x1440)
      • Internet:
      • Virgin Media 100mb

    Possible to define HMTL file as table structure with content separate?

    Hello,

    I'll elaborate on the title a little. I need to produce a logging file for an application that I'm doing and it has to take the form of a HTML file. Is there a way that I can define a general table structure, ie. the standard table, header tags etc, then actually define the content that populates the table at the end of the file?

    I'm using C# btw and I only ask because I want to just keep appending to the file and the new data to get added into the table, without the need to remove all the closing tags and then rewrite them again.

    I'm sure that this is possible, but if any HTML whizzkids are out there, any help would be appreciate.

    Jonny

    PS (Yes, the title was meant to say HTML...)

  2. #2
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Possible to define HMTL file as table structure with content separate?

    not with raw html, no.

  3. #3
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Possible to define HMTL file as table structure with content separate?

    the easy yet nicest way, would be with XSLT.

    You produce an XML structure with your data (piss easy).

    You 'transofrm' that XML into HTML.

    so you have a class like

    Code:
    public class FOO { 
    public string Feild1 {get;set;}
    public string Feild2 {get;set;}
    }
    you then serialize that, with the XML seriealizer, but we don't want to write it to a file, so we do it to a stirng.

    Code:
                
    // serialize data to xml string.
                StringBuilder xmlsb = new StringBuilder();
                XmlWriter xmlWriter = XmlWriter.Create(xmlsb);
                XmlSerializer xmlSerializer = new XmlSerializer(typeof (FOO[]));
    // an array of FOO.
                xmlSerializer.Serialize(xmlWriter, new FOO[] {foo1,foo2});
    Then we load the compiled Transform.
    Code:
                XslCompiledTransform t = new XslCompiledTransform(false);
                t.Load(@"report.xslt");
    
                TextReader tr = new StringReader(xmlsb.ToString());
                XmlReader xmlR = XmlReader.Create(tr);
                StringBuilder sb = new StringBuilder();
                XmlWriter xmlW = XmlWriter.Create(sb);
                t.Transform(xmlR, xmlW);
                xmlWriter.Close();
    That expects an XSLT file called report.

    your then left with a string builder (sb) that has the 'transformed' XML in HTML.

    Its really easy to debug and maintain, plus going forward you have the XML which is always useful for interopping with other apps.
    throw new ArgumentException (String, String, Exception)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 63
    Last Post: 14-11-2011, 09:17 AM
  2. Need help on my maxtor harddrives
    By arthurleung in forum PC Hardware and Components
    Replies: 10
    Last Post: 12-06-2007, 09:40 PM
  3. Nero vision express saying:'Burn process failed'
    By johnnr892 in forum Help! Quick Relief From Tech Headaches
    Replies: 15
    Last Post: 11-12-2005, 11:43 PM
  4. Nero or Burner ?
    By Foxile in forum Help! Quick Relief From Tech Headaches
    Replies: 30
    Last Post: 04-04-2005, 07:31 AM
  5. Dodgy DVD-r's ?
    By starside in forum Help! Quick Relief From Tech Headaches
    Replies: 12
    Last Post: 27-03-2005, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •