
XMLReader::moveToAttributeNs 메서드는 XML 문서에서 특정 속성의 이름스페이스 URI를 얻는 데 사용할 수 있습니다.
속성이름스페이스 URI를 얻기 위한 절차는 다음과 같습니다.
1. XMLReader 객체를 초기화합니다.
2. XMLReader::read() 메서드를 사용하여 XML 문서의 시작점으로 이동합니다.
3. XMLReader::moveToAttributeNs() 메서드를 사용하여 특정 속성의 이름스페이스 URI를 얻습니다.
예를 들어, 다음 XML 문서에서 "id" 속성의 이름스페이스 URI를 얻으려면 다음과 같이 할 수 있습니다.
#hostingforum.kr
php
$xml = new DOMDocument();
$xml->loadXML('');
$xmlReader = new XMLReader();
$xmlReader->XML($xml->saveXML());
$xmlReader->read();
$xmlReader->moveToAttributeNs('ns', 'id');
echo $xmlReader->getAttributeNamespace('ns'); // http://example.com/ns
위의 예제에서, XMLReader::moveToAttributeNs() 메서드를 사용하여 "id" 속성의 이름스페이스 URI를 얻은 후, XMLReader::getAttributeNamespace() 메서드를 사용하여 이름스페이스 URI를 출력합니다.
2025-05-22 14:20