XML in C # - reading from resources, manipulating and displaying

I would like to do the following and cannot find an elegant way:

  • Read the XML template in System.Xml.XmlDocument
  • Fill it with data from my user interface
  • Convert it using XSLTI wrote
  • Apply CSSStyle Sheet
  • Relate it to a control WebBrowser

I am currently reading it from a file on disk, filling it in, and then saving it back to disk after it is filled. I refer to XSLTin the template and CSSin XSLT, and then use the method WebBrowser.Navigate([filename])to display the XML file.

Obviously, when I come to deploy this app, it will be terribly disturbed, because the file does not exist on the drive, and I can not rely on files XSLTand CSSin XML, because they are resources. I plan to include the template as a resource, but I cannot find a neat way from there.

Any help is much appreciated

+5
source share
4 answers

Quick question. Why do I need an Xml template? If you already know the diagram before hand, just generate the full Xml in your code. No template file upload required.

+1
source

Keith, , LINQ , . , .Net 2.0 , (, , !), LINQ .

CSS XSLT, System.Xml.Xsl.XslCompiledTransform XML . WebBrowser.DocumentText XML Componentet WebBrowser, , , .

, -, . , LINQ, , , ? XML, , . , , !

+1

Linq to XML - Xml. , System.Xml.XmlDocument.

, XSLT CSS, XHTML CSS? , XSLT CSS .

- , , - CHM . , , , .

0

WebBrowser, WPF, CSS, 4. Resource Hacker "" res:// (http://msdn.microsoft.com/en-us/library/aa767740(VS.85).aspx) Microsoft 1990- .

HTML-. -:

void WireUpBrowserEvents()
{

    HtmlElement table = this._browser.Document.GetElementById( "UnitFormsTable" );
    if ( table != null )
    {
        HtmlElementCollection thead = table.GetElementsByTagName( "thead" );
        if ( ( thead != null ) && ( thead.Count == 1 ) )
        {
            HtmlElementCollection links = thead[0].GetElementsByTagName( "a" );
            if ( ( links != null ) && ( links.Count > 0 ) )
            {
                foreach ( HtmlElement a in links )
                {
                    a.Click += new HtmlElementEventHandler( XslSort_Click );
                }
            }
        }
    }
}

void XslSort_Click( object sender, HtmlElementEventArgs e )
{
    e.ReturnValue = false;

    if ( this._xslSortWorker.IsBusy ) return;

    if ( sender is HtmlElement )
    {
        HtmlElement a = sender as HtmlElement;
        this._browser.Hide();
        this._browserMessage.Visible = true;
        this._browserMessage.Refresh();
        this._xslSortWorker.RunWorkerAsync( a.Id );
    }
}

, , HtmlElement HtmlElementCollection System.Windows.Forms. , :)

0

All Articles