docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화

Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
Antigravity Agent
2026-07-05 00:10:59 +09:00
parent a397bc4720
commit 1cfd3bbb56
1495 changed files with 68534 additions and 27 deletions
@@ -0,0 +1,76 @@
---
id: php-xml-parser-expat
title: "PHP XML Parser Expat"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["Expat parser", "event-based XML", "PHP XML Expat 파서"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.88
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["php", "programming", "w3schools", "xml", "expat"]
raw_sources: ["https://www.w3schools.com/php/php_xml_parser_expat.asp"]
applied_in: []
github_commit: ""
---
# [[PHP XML Parser Expat]]
## 🎯 한 줄 통찰 (One-line insight)
The Expat parser reduces even a simple tag like `<from>Jani</from>` into exactly THREE distinct events — start element, character data, end element — and each event type is routed to its own separate handler function, meaning parsing an XML document is really about writing three small callback functions rather than writing traversal logic. [S1]
## 🧠 핵심 개념 (Core concepts)
- **XML Expat Parser** — event-based, non-validating (ignores DTDs), fast, low-memory; part of PHP core. [S1]
- **Three-event model** — any tag decomposes into: start element, CDATA/character data, end element. [S1]
- **`xml_parser_create()`** — initializes the parser. [S1]
- **`xml_set_element_handler($parser, "start", "stop")`** — registers separate functions for opening and closing tags. [S1]
- **`xml_set_character_data_handler($parser, "char")`** — registers the function for text content between tags. [S1]
- **`xml_parse($parser, $data, $isFinal)`** — feeds a chunk of data to the parser; `feof($stream)` signals whether this is the final chunk. [S1]
- **`xml_error_string()` / `xml_parser_free()`** — error reporting and resource cleanup. [S1]
## 📖 세부 내용 (Details)
- Handler functions: `function start($parser, $element_name, $element_attrs) { switch($element_name) { case "NOTE": echo "-- Note --<br>"; break; case "TO": echo "To: "; break; ... } } function stop($parser, $element_name) { echo "<br>"; } function char($parser, $data) { echo $data; }`. [S1]
- Full parse pipeline: `$stream = fopen("note.xml", "r"); $parser = xml_parser_create(); xml_set_element_handler($parser, "start", "stop"); xml_set_character_data_handler($parser, "char"); while ($data = fread($stream, 4096)) { xml_parse($parser, $data, feof($stream)) or die(...); } xml_parser_free($parser); fclose($stream);`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
소스에서 모순되는 정보는 발견되지 않음.
## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — note.xml을 이벤트 핸들러로 파싱해 "To: Tove" 형태로 출력하는 것이 이벤트 기반 파싱의 대표 실전 사례다. [S1]
## 💻 코드 패턴 (Code patterns)
Full Expat parsing pipeline with handler functions (PHP):
```php
$stream = fopen("note.xml", "r");
$parser = xml_parser_create();
xml_set_element_handler($parser, "start", "stop");
xml_set_character_data_handler($parser, "char");
while ($data = fread($stream, 4096)) {
xml_parse($parser, $data, feof($stream)) or die("XML Error");
}
xml_parser_free($parser);
fclose($stream);
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.88
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[PHP Tutorial]]
- **관련 개념:** [[PHP XML SimpleXML Get]], [[PHP XML DOM]]
- **참조 맥락:** 이벤트 기반 파싱 — 트리 기반 DOM 파서 챕터와 대비됨.
## 📚 출처 (Sources)
- [S1] W3Schools — PHP XML Expat Parser — https://www.w3schools.com/php/php_xml_parser_expat.asp
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP XML Expat Parser" page (Astra wiki-curation, P-Reinforce v3.1 format).