(Deprecated) Encoding Support

 

[Deprecated. Do not use. Superseded by SAX2 API/MSXML 3.0]

The same encoding support is provided for each of the different methods of input. To provide Unicode data, the input stream or buffer must start with a Unicode Byte Order Mark (BOM) 0xFFFE or 0xFEFF, depending on whether the Unicode is little or big endian. If no byte order mark is present, it is assumed to be UTF-8. To specify something other than UTF-8, use an XML declaration with an encoding attribute at the beginning of the input. For example, the following specifies a common encoding for Japanese on Microsoft platforms.

<?xml version="1.0" encoding="shift_jis"?>  

The XML parser recognizes UTF-8 and UCS-2 directly. For all other character sets, MLang is used to perform conversions.

Example Parser Usage

The following example assumes you have an IStream and NodeFactory already.

HRESULT ParseXML{IStream* input, IXMLNodeFactory* f)  
{  
    IXMLParser* xp;  
    HRESULT hr;  
    checkhr(CoCreateInstance(CLSID_XMLParser, NULL, CLSCTX_INPROC_SERVER,   
      IID_IXMLParser, (void**)&xp);  
    checkhr(xp->SetInput(input));  
    checkhr(xp->SetFactory(f));  
    hr = xp->Run(-1);  
    xp->Release();  
    return hr;  
}