Solved

Rendering an XML Stream II

Posted on 2001-06-24
6
340 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
I starting with php 12 143
 shows up in Outlook, not OWA or on phone 3 81
jQuery Date picker not working 16 272
How to get statistic's from a competitors website?! 1 151
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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…

752 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