Share via


SetInput (Compact 7)

3/12/2014

This interface sets the input source of the XML document that is to be parsed.

Syntax

HRESULT SetInput (
    IUnknown* pInput
);

Arguments

  • pInput
    [in] The input stream to be parsed

Return Value

This interface returns S_OK if no error is generated.

Remarks

The input source can be one of the following types:

  • A class that is derived from IStream or ISequentialStream. The reader will use defaults for all the additional properties of the input. IMalloc and base URI will be empty. The reader will be not use alternative character set encoding.
  • IXmlReaderInput. The input is described by an instance of the IXmlReaderInput class. By using an instance of this class, the user can specify additional properties of the input (such as alternative character set encoding and base URI). Use CreateXmlReaderInputWithEncodingCodePage or CreateXmlReaderInputWithEncodingName to achieve an instance of IXmlReaderInput.
  • NULL. This resets the input, releasing the previously set input object.

The following code sets the input source for a reader:

//Open read-only input stream
if (FAILED(hr = SHCreateStreamOnFile(argv[1], STGM_READ, &pFileStream)))
{
    wprintf(L"Error creating file reader, error is %08.8lx", hr);
    return -1;
}

if (FAILED(hr = CreateXmlReader(__uuidof(IXmlReader), (void**) &pReader, NULL)))
{
    wprintf(L"Error creating xml reader, error is %08.8lx", hr);
    return -1;
}

if (FAILED(hr = pReader->SetProperty(XmlReaderProperty_DtdProcessing, DtdProcessing_Prohibit)))
{
    wprintf(L"Error setting XmlReaderProperty_DtdProcessing, error is %08.8lx", hr);
    return -1;
}

if (FAILED(hr = pReader->SetInput(pFileStream)))
{
    wprintf(L"Error setting input for reader, error is %08.8lx", hr);
    return -1;
}

See Also

Reference

IXmlReader Methods
IStream
ISequentialStream
IMalloc
IXmlReaderInput
CreateXmlReaderInputWithEncodingCodePage
CreateXmlReaderInputWithEncodingName
IXmlReader Properties
Error Codes