Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Rendering an XML Stream II

Posted on 2001-06-24
6
Medium Priority
?
350 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
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 1040 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

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!

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

971 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