Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:53:11+00:00 2026-06-15T08:53:11+00:00

I’m trying to output a formatted XML document from a DOM object into a

  • 0

I’m trying to output a formatted XML document from a DOM object into a string, as shown in the code below. The thing is, while the dom->get_xml() method does return a value, the MXXMLWriter->output does not, as you can see on the screenshot. All method calls return S_OK. What could be the issue here?

Here’s my code:

CComPtr<IMXWriter> w;
HRESULT hr;
hr = w.CoCreateInstance(__uuidof(MXXMLWriter), NULL, CLSCTX_INPROC_SERVER);

hr = w->put_indent(VARIANT_TRUE);

CComPtr<ISAXXMLReader> rd;
hr = rd.CoCreateInstance(__uuidof(SAXXMLReader60), NULL, CLSCTX_INPROC_SERVER);

CComPtr<ISAXContentHandler> hc;
hr = w.QueryInterface<ISAXContentHandler>(&hc);
CComPtr<ISAXErrorHandler> he;
hr = w.QueryInterface<ISAXErrorHandler>(&he);
CComPtr<ISAXDTDHandler> hd;
hr = w.QueryInterface<ISAXDTDHandler>(&hd);

hr = rd->putContentHandler(hc);
hr = rd->putErrorHandler(he);
hr = rd->putDTDHandler(hd);
hr = rd->putProperty(L"http://xml.org/sax/properties/lexical-handler", CComVariant(w));
hr = rd->putProperty(L"http://xml.org/sax/properties/declaration-handler", CComVariant(w));

BSTR body = ::SysAllocStringLen(NULL, 1024);
ZeroMemory(body, 1024 * sizeof(OLECHAR));
CComVariant out(body);
w->put_encoding(CComBSTR(L"utf-8"));
hr = w->put_output(out);
hr = rd->parse(CComVariant(dom));

dom->get_xml(&xmlStr);

return std::wstring(xmlStr);

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:53:12+00:00Added an answer on June 15, 2026 at 8:53 am

    The documentation states that

    Output can be:

    • Any implementation of the IStream interface. (The resulting document will be written into the provided IStream).
    • A string.
    • A DOMDocument object.

    For more information about setting the output property to a DOMDocument object, see Create a DOMDocument Object from SAX Events.

    Setting this property to the empty value (VT_EMPTY or ” “) will return output to the internal string and reset it

    You apparently want the writer to fill the string. So it is suggested to use an empty string to instruct writer to fill its internal buffer and then you can obtain it via property getter.

    You instead attempt to provide your own buffer to be filled, and this is the advertised behavior of the writer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.