Share via


WsReadToStartElement 함수(webservices.h)

필요한 경우 공백 및 주석을 건너뛰는 다음 시작 요소로 판독기를 진행합니다. 필요에 따라 요소의 localName 및 네임스페이스를 확인할 수도 있습니다.

구문

HRESULT WsReadToStartElement(
  [in]           WS_XML_READER       *reader,
  [in, optional] const WS_XML_STRING *localName,
  [in, optional] const WS_XML_STRING *ns,
                 BOOL                *found,
  [in, optional] WS_ERROR            *error
);

매개 변수

[in] reader

start 요소로 읽을 판독기입니다.

[in, optional] localName

요소가 있어야 하는 localName 이름입니다. NULL이면 localName이 허용됩니다.

[in, optional] ns

요소가 있어야 하는 네임스페이스입니다. NULL이면 모든 네임스페이스가 허용됩니다.

found

지정된 경우 요소를 찾을지 여부와 localName 및 네임스페이스(지정된 경우)가 일치하는지 여부를 나타냅니다. 지정하지 않고 요소를 찾을 수 없거나 localName 및 네임스페이스가 일치하지 않으면 WS_E_INVALID_FORMAT 반환됩니다. ( Windows Web Services 반환 값을 참조하세요.)

[in, optional] error

함수가 실패할 경우 추가 오류 정보를 저장할 위치를 지정합니다.

반환 값

이 함수는 이러한 값 중 하나를 반환할 수 있습니다.

반환 코드 설명
WS_E_INVALID_FORMAT
입력 데이터가 예상 형식이 아니거나 예상 값이 없습니다.
WS_E_QUOTA_EXCEEDED
할당량을 초과했습니다.

설명

다음 XML을 고려합니다.

<!-- A purchase order -->
        <PurchaseOrder xmlns='http://tempuri.org'>
            <Item>
                Pencil
            </Item>
        </PurchaseOrder>

다음 예제에서는 판독기가 문서의 여러 위치에 배치될 때 WsReadToStartElement 의 동작을 보여 줍니다.

WS_XML_STRING purchaseOrder = WS_XML_STRING_VALUE("PurchaseOrder");
WS_XML_STRING item = WS_XML_STRING_VALUE("Item");
WS_XML_STRING ns = WS_XML_STRING("http://tempuri.org");
WS_ERROR* error = NULL;

// Example 1: Reader on comment, element has specified name and namespace, found argument is not provided
HRESULT hr = WsReadToStartElement(reader, &purchaseOrder, &ns, NULL, error);
// hr = NOERROR, the reader is positioned on <PurchaseOrder>

// Example 2: Reader on comment, element has specified name and namespace, found argument is provided
BOOL found;
HRESULT hr = WsReadToStartElement(reader, &purchaseOrder, &ns, found, error);
// hr = NOERROR, found = TRUE, the reader is positioned on <PurchaseOrder>

// Example 3: Reader on comment, element does not have specified name and namespace, found argument is not provided
HRESULT hr = WsReadToStartElement(reader, &item, &ns, NULL, error);
// hr = WS_E_INVALID_FORMAT, the reader is faulted

// Example 4: Reader on comment, element does not have specified name and namespace, found argument is provided
BOOL found;
HRESULT hr = WsReadToStartElement(reader, &item, &ns, &found, error);
// hr = NOERROR, found = FALSE, the reader is positioned on <PurchaseOrder>

// Example 5: Reader on comment, name and namespace not specified, found argument is provided
BOOL found;
HRESULT hr = WsReadToStartElement(reader, NULL, NULL, &found, error);
// hr = NOERROR, found = TRUE, the reader is positioned on <PurchaseOrder>

// Example 6: Reader on </Item>, name and namespace not specified, found argument is not provided
HRESULT hr = WsReadToStartElement(reader, NULL, NULL, NULL, error);
// hr = WS_E_INVALID_FORMAT, the reader is faulted

// Example 7: Reader on </Item>, name and namespace not specified, found argument is provided
BOOL found;
HRESULT hr = WsReadToStartElement(reader, NULL, NULL, &found, error);
// hr = NOERROR, found = FALSE, the reader is positioned on </Item>

WsReadToStartElement에서 요소가 발견되었음을 나타내는 경우 WsReadStartElement 또는 WsReadNode를 사용하여 시작 요소를 지나 요소의 콘텐츠로 판독기를 이동할 수 있습니다.

WsSkipNode 는 요소를 건너뛰고 해당 끝 요소 다음에 판독기가 WS_XML_NODE 배치된 모든 자식 요소를 건너뛸 수 있습니다.

이 함수는 WsReadNode에 나열된 이유 중 어떤 이유로든 실패할 수 있습니다.

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 webservices.h
라이브러리 WebServices.lib
DLL WebServices.dll