Solved

Rendering an XML Stream II

Posted on 2001-06-24
6
336 Views
Last Modified: 2013-11-20
Hi All,
With XML/XSL adding such great capabilities for formatting output I would like to be able to stream XML data into a CHTMLView. While the XSL sheet can reside in the program directory, the XML is produced dynamically as output from various calculations with the view rendering it in the same way that it does if you load an xml document from the local drive. Is it possible to insert items into an XML document and have it render (using the XSL sheet) as each element is added as with HTML? Can anyone show me a way of going about this?

I have got as far as this:

// Load the default xml document
CString sAppName=AfxGetAppName();
CString sResourceID;
sResourceID.Format("%d", IDR_EMPTY_XML);
CString sNavigatePath;
sNavigatePath ="res://"+sAppName+".exe/"+sResourceID;
Navigate2(sNavigatePath);

Where the resource in this case is inserted as an HTML page containing XML.  ie

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="file://c:\OLSSAMP.xsl"?>
<!-- Here begins the XML data -->
<OUTPUT>
 <METHOD ID="OLS">
   <COMMAND>OLS CONSUME INCOME PRICE / ANOVA PCOV</COMMAND>
 </METHOD>  
</OUTPUT>

This loads an empty (but properly rendered XML document) and from there I was hoping to be able to insert elements and have the view update the element based on the stylesheet.  Using the methods suggested by Dan Rollins:
1) pElem->put_innerHTML( bstrHtml );  using get_body()
  or
2) pPersistStreamInit->Load( pStm );  using CreateStreamOnHGlobal(.)
 
(which are both methods for inserting HTML that is automatically rendered correctly) do not cause the page to render the XML with the XSL formatting - rather the XML is treated as HTML with unrecognised tags ie. inserted as plain text.

Finally if there is an alternative to XSL that will cause the XML stream (or element inserts) to render (eg. dynamic HTML methods of working with XML) than that would be also be fine.

Thanks in advance for any suggestions.  Roll on DXML....

Regards

David
0
Comment
Question by:Rupreck
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6224372
what I do is this

1) load your XML into an XMLDocument
2) load the XSLT into an XMLDocument
3) transform using transformNode
4) load the result into a HTMLDocument
0
 

Author Comment

by:Rupreck
ID: 6227098
Thanks Shaun, this looks useful.  Do you have any sample code that will do this, I have no experience with using the XML Dom object in C++.  

I take it that 1) allows the loading of an xml portion (node) that is then inserted into an existing rendered XML document properly formatted?

Regards
David
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6227660
> Do you have any sample code that will do this

sadly no - I've only ever done this inside webapages - but it is easy to do if you know how to create COM objects

1) create 2 IXMLDOMDocument objects
2) set the async property on both to false
3) load 1 with the xml and the other with the xsl documents
4) BSTR bstrHTML=xmlDoc.transformNode(xslDoc);
5) insert the html into your browser (which you seem to know how to do)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 9

Accepted Solution

by:
ShaunWilde earned 260 total points
ID: 6227680
> Do you have any sample code that will do this

sadly no - I've only ever done this inside webapages - but it is easy to do if you know how to create COM objects

1) create 2 IXMLDOMDocument objects
2) set the async property on both to false
3) load 1 with the xml and the other with the xsl documents
4) BSTR bstrHTML=xmlDoc.transformNode(xslDoc);
5) insert the html into your browser (which you seem to know how to do)
0
 

Author Comment

by:Rupreck
ID: 6270577
Now I just have to figure how to do it in C++
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6282041
just ask if you have any problems I might be able to help further
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now