Solved

Rendering an XML Stream II

Posted on 2001-06-24
6
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to count occurrences of each item in an array.
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.
Suggested Courses

622 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