使用DOM创建文档对象的时候,怎么指定文档类型? 也就是说,下面这句怎么实现,<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102.dtd"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我已经解决了,用的是sax2.0,现贴出来共勉HRESULT hr;// ISAXXMLReaderPtr pRdr = NULL; IMXWriterPtr pWr = NULL; hr = CoInitialize(NULL); USES_CONVERSION; ISAXDTDHandlerPtr dtd=NULL; hr = pWr.CreateInstance(__uuidof(MXXMLWriter40)); dtd = pWr; pWr->indent = VARIANT_TRUE; pWr->omitXMLDeclaration =VARIANT_TRUE; ISAXContentHandlerPtr spContentHandler=NULL; spContentHandler = pWr; //Start the document by adding the XML declaration. hr = spContentHandler->startDocument (); char szPI[]= "version='1.0' standalone='no'"; //Step 1: Create the XML declaration. hr = spContentHandler->processingInstruction(L"xml", 3, A2W(szPI), strlen(szPI));//xml版本声明//加DTD验证 ISAXLexicalHandlerPtr lexh; lexh = pWr; lexh->startDTD(L"svg",3,L"-//W3C//DTD SVG 20001102//EN",28,L"http://www.w3.org/TR/2000/CR-SVG-20001102.dtd",45);// lexh->endDTD(); //Step 2: Create the root ---svg element. IMXAttributesPtr pMXAttr = NULL; ISAXAttributesPtr spAttributes = NULL; hr = pMXAttr.CreateInstance(__uuidof(SAXAttributes40)); pMXAttr->addAttribute(L"",L"Width",L"Width","float","3200"); pMXAttr->addAttribute(L"",L"Height",L"Height","float","2400"); pMXAttr->addAttribute(L"",L"xmlns",L"xmlns","string","http://www.w3.org/2000/svg"); spAttributes= pMXAttr; hr = spContentHandler->startElement(L"", 0, L"svg",3, L"svg",3,spAttributes); //Step 3: 添加子元素 for (POSITION pos = m_objects.GetHeadPosition(); pos != NULL; ) { CDrawObj* pObj = m_objects.GetNext(pos); pObj->WriteCont(pWr); } //结束根元素,和文档 hr = spContentHandler->endElement(L"",0,L"svg",3, L"svg",3); hr = spContentHandler->endDocument (); vc++ 用ListBox控件显示文本闪烁的问题? 窗口如何永远置底? 郁闷了,今天第一次被人认为不是做程序的 父子线程,同级别的线程之间的通信问题 CreateMutex 的问题 小弟最近做了个小软件,想以共享软件形式发布,大家分析一下市场前景如何? 系统加用户口令怎么加? 如何通过编程获取Outook的联系人?立即结帐。谢谢! 关于接口调用问题,请帮忙!谢谢!急! 难道就没人能回答吗?? 上QQ发送信息的时候,自动弹出一些不要的信息(比如说黄色网站地址啊)并且自动发送出去,请问这是什么病毒 怎么在从CListView继承的View中添加一个标题栏?
HRESULT hr;
// ISAXXMLReaderPtr pRdr = NULL;
IMXWriterPtr pWr = NULL;
hr = CoInitialize(NULL);
USES_CONVERSION;
ISAXDTDHandlerPtr dtd=NULL;
hr = pWr.CreateInstance(__uuidof(MXXMLWriter40));
dtd = pWr;
pWr->indent = VARIANT_TRUE;
pWr->omitXMLDeclaration =VARIANT_TRUE;
ISAXContentHandlerPtr spContentHandler=NULL;
spContentHandler = pWr;
//Start the document by adding the XML declaration.
hr = spContentHandler->startDocument ();
char szPI[]= "version='1.0' standalone='no'"; //Step 1: Create the XML declaration.
hr = spContentHandler->processingInstruction(L"xml", 3, A2W(szPI), strlen(szPI));//xml版本声明
//加DTD验证
ISAXLexicalHandlerPtr lexh;
lexh = pWr;
lexh->startDTD(L"svg",3,L"-//W3C//DTD SVG 20001102//EN",28,L"http://www.w3.org/TR/2000/CR-SVG-20001102.dtd",45);// lexh->endDTD();
//Step 2: Create the root ---svg element.
IMXAttributesPtr pMXAttr = NULL;
ISAXAttributesPtr spAttributes = NULL;
hr = pMXAttr.CreateInstance(__uuidof(SAXAttributes40));
pMXAttr->addAttribute(L"",L"Width",L"Width","float","3200");
pMXAttr->addAttribute(L"",L"Height",L"Height","float","2400");
pMXAttr->addAttribute(L"",L"xmlns",L"xmlns","string","http://www.w3.org/2000/svg");
spAttributes= pMXAttr;
hr = spContentHandler->startElement(L"", 0, L"svg",3, L"svg",3,spAttributes);
//Step 3: 添加子元素
for (POSITION pos = m_objects.GetHeadPosition(); pos != NULL; )
{
CDrawObj* pObj = m_objects.GetNext(pos);
pObj->WriteCont(pWr);
}
//结束根元素,和文档
hr = spContentHandler->endElement(L"",0,L"svg",3, L"svg",3);
hr = spContentHandler->endDocument ();