也就是说,下面这句怎么实现,
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
     "http://www.w3.org/TR/2000/CR-SVG-20001102.dtd">

解决方案 »

  1.   

    我已经解决了,用的是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 ();