<?xml version="1.0" encoding="utf-8"?>
<CATEGORIES type="day">
<CATEGORY label="22" data="20101022"/>
<CATEGORY label="23" data="20101023"/>
</CATEGORIES>
// XML 파일 열고 루트 테그 가져오기
$dom = DOMDocument::load($filepath);
$temp = $dom->getElementsByTagName('CATEGORIES');
$root = $temp->item(0);
// 노드 추가 하기 위해 추가할 위치 검색
// 여기서는 날짜를 기준으로 정렬하는 부분인데, 현재 입력된 날짜가 크면 다음으로, 작으면 그 노드의 앞을 지정
$childs = $root->getElementsByTagName('CATEGORY');
for ($L1 = 0, $C1 = $childs->length; $L1 < $C1; $L1++)
{
$child = $childs->item($L1);
$label = $child->getAttribute('label');
if ($data == $label) { $isFound = -1; break; }
elseif ($data < $label) { $isFound = 1; break; }
}
// 신규 XML 파일 생성
// <?xml version="1.0" encoding="utf-8"?><CATEGORIES type="day" />
$dom = new DOMDocument('1.0', 'utf-8');
$root = $dom->createElement('CATEGORIES');
$root->setAttribute('type', 'day');
$dom->appendChild($root);
// 신규 노드 생성
//<CATEGORY label="22" data="20101022"/>
$node = $dom->createElement('CATEGORY');
$node->setAttribute('label', '22');
$node->setAttribute('data', '20101022');
// 추가할 위치가 있는 경우 그 앞에 추가하고, 없다면 맨 뒤의 노드에 추가
if ($isFound == 1) { $root->insertBefore($node, $child); }
elseif ($isFound == 0) { $root->appendChild($node); }
// 저장
//echo htmlspecialchars($dom->saveXML());
createDirectory($filepath);
$dom->save($filepath);
chmod($filepath, 0646);
댓글 1개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 200 | ||
| 8229 | 9년 전 | 180 | ||
| 8228 |
커네드커네드
|
9년 전 | 218 | |
| 8227 | 9년 전 | 260 | ||
| 8226 | 9년 전 | 279 | ||
| 8225 | 9년 전 | 265 | ||
| 8224 | 9년 전 | 270 | ||
| 8223 | 9년 전 | 247 | ||
| 8222 |
|
9년 전 | 309 | |
| 8221 | 9년 전 | 204 | ||
| 8220 | 9년 전 | 250 | ||
| 8219 | 9년 전 | 223 | ||
| 8218 | 9년 전 | 265 | ||
| 8217 |
star3840
|
9년 전 | 221 | |
| 8216 | 9년 전 | 304 | ||
| 8215 | 9년 전 | 249 | ||
| 8214 | 9년 전 | 351 | ||
| 8213 | 9년 전 | 308 | ||
| 8212 | 9년 전 | 226 | ||
| 8211 | 9년 전 | 394 | ||
| 8210 | 9년 전 | 388 | ||
| 8209 | 9년 전 | 469 | ||
| 8208 | 9년 전 | 349 | ||
| 8207 | 9년 전 | 366 | ||
| 8206 |
|
9년 전 | 312 | |
| 8205 | 9년 전 | 283 | ||
| 8204 | 9년 전 | 273 | ||
| 8203 | 9년 전 | 352 | ||
| 8202 | 9년 전 | 261 | ||
| 8201 | 9년 전 | 305 | ||
| 8200 | 9년 전 | 307 | ||
| 8199 | 9년 전 | 334 | ||
| 8198 | 9년 전 | 302 | ||
| 8197 | 9년 전 | 289 | ||
| 8196 | 9년 전 | 714 | ||
| 8195 | 9년 전 | 297 | ||
| 8194 | 9년 전 | 401 | ||
| 8193 | 9년 전 | 322 | ||
| 8192 | 9년 전 | 322 | ||
| 8191 | 9년 전 | 282 | ||
| 8190 | 9년 전 | 262 | ||
| 8189 | 9년 전 | 326 | ||
| 8188 | 9년 전 | 258 | ||
| 8187 | 9년 전 | 276 | ||
| 8186 | 9년 전 | 277 | ||
| 8185 | 9년 전 | 445 | ||
| 8184 | 9년 전 | 226 | ||
| 8183 | 9년 전 | 429 | ||
| 8182 | 9년 전 | 302 | ||
| 8181 | 9년 전 | 252 | ||
| 8180 | 9년 전 | 835 | ||
| 8179 | 9년 전 | 614 | ||
| 8178 | 9년 전 | 466 | ||
| 8177 |
kiplayer
|
9년 전 | 464 | |
| 8176 | 9년 전 | 503 | ||
| 8175 | 9년 전 | 383 | ||
| 8174 | 9년 전 | 378 | ||
| 8173 | 9년 전 | 466 | ||
| 8172 | 9년 전 | 348 | ||
| 8171 | 9년 전 | 310 | ||
| 8170 | 9년 전 | 429 | ||
| 8169 |
커네드커네드
|
9년 전 | 378 | |
| 8168 | 9년 전 | 466 | ||
| 8167 | 9년 전 | 451 | ||
| 8166 | 9년 전 | 356 | ||
| 8165 | 9년 전 | 289 | ||
| 8164 | 9년 전 | 421 | ||
| 8163 | 9년 전 | 425 | ||
| 8162 | 9년 전 | 413 | ||
| 8161 | 9년 전 | 430 | ||
| 8160 |
|
9년 전 | 645 | |
| 8159 | 9년 전 | 592 | ||
| 8158 | 9년 전 | 389 | ||
| 8157 | 9년 전 | 512 | ||
| 8156 | 9년 전 | 385 | ||
| 8155 | 9년 전 | 399 | ||
| 8154 |
00년생용띠
|
9년 전 | 714 | |
| 8153 | 9년 전 | 361 | ||
| 8152 |
|
9년 전 | 531 | |
| 8151 | 9년 전 | 528 | ||
| 8150 | 9년 전 | 647 | ||
| 8149 |
Jangfolk
|
9년 전 | 503 | |
| 8148 | 9년 전 | 316 | ||
| 8147 | 9년 전 | 504 | ||
| 8146 | 9년 전 | 586 | ||
| 8145 | 9년 전 | 551 | ||
| 8144 | 9년 전 | 511 | ||
| 8143 | 9년 전 | 333 | ||
| 8142 | 9년 전 | 558 | ||
| 8141 | 9년 전 | 496 | ||
| 8140 | 9년 전 | 1066 | ||
| 8139 | 9년 전 | 404 | ||
| 8138 |
전갈자리남자
|
9년 전 | 515 | |
| 8137 | 9년 전 | 556 | ||
| 8136 | 9년 전 | 880 | ||
| 8135 |
|
9년 전 | 925 | |
| 8134 |
PlayPixel
|
9년 전 | 669 | |
| 8133 |
|
9년 전 | 571 | |
| 8132 | 9년 전 | 602 | ||
| 8131 | 9년 전 | 962 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기