<?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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6530 |
퍼블리셔강
|
12년 전 | 654 | |
| 6529 | 12년 전 | 1308 | ||
| 6528 | 12년 전 | 629 | ||
| 6527 | 12년 전 | 792 | ||
| 6526 | 12년 전 | 6581 | ||
| 6525 | 12년 전 | 552 | ||
| 6524 | 12년 전 | 843 | ||
| 6523 | 12년 전 | 496 | ||
| 6522 | 12년 전 | 541 | ||
| 6521 | 12년 전 | 802 | ||
| 6520 | 12년 전 | 744 | ||
| 6519 | 12년 전 | 1745 | ||
| 6518 |
가슴시린하늘
|
12년 전 | 1727 | |
| 6517 | 12년 전 | 1367 | ||
| 6516 | 12년 전 | 5228 | ||
| 6515 | 12년 전 | 1502 | ||
| 6514 | 12년 전 | 1602 | ||
| 6513 | 12년 전 | 956 | ||
| 6512 | 12년 전 | 1988 | ||
| 6511 | 12년 전 | 1376 | ||
| 6510 | 12년 전 | 3079 | ||
| 6509 |
프로프리랜서
|
12년 전 | 2551 | |
| 6508 |
프로프리랜서
|
12년 전 | 1900 | |
| 6507 |
프로프리랜서
|
12년 전 | 2376 | |
| 6506 |
프로프리랜서
|
12년 전 | 1859 | |
| 6505 |
프로프리랜서
|
12년 전 | 1635 | |
| 6504 | 12년 전 | 1046 | ||
| 6503 | 12년 전 | 1132 | ||
| 6502 |
프로프리랜서
|
12년 전 | 5558 | |
| 6501 |
프로프리랜서
|
12년 전 | 2607 | |
| 6500 |
프로프리랜서
|
12년 전 | 3092 | |
| 6499 |
프로프리랜서
|
12년 전 | 1752 | |
| 6498 |
프로프리랜서
|
12년 전 | 1466 | |
| 6497 | 12년 전 | 816 | ||
| 6496 |
yunkiri486
|
12년 전 | 1816 | |
| 6495 | 12년 전 | 924 | ||
| 6494 | 12년 전 | 1493 | ||
| 6493 | 12년 전 | 2765 | ||
| 6492 |
오늘도망했다
|
12년 전 | 2339 | |
| 6491 |
오늘도망했다
|
12년 전 | 1678 | |
| 6490 |
오늘도망했다
|
12년 전 | 6661 | |
| 6489 |
오늘도망했다
|
12년 전 | 2501 | |
| 6488 |
홈피119
|
12년 전 | 704 | |
| 6487 | 12년 전 | 688 | ||
| 6486 | 12년 전 | 1412 | ||
| 6485 | 12년 전 | 2055 | ||
| 6484 | 12년 전 | 905 | ||
| 6483 | 12년 전 | 724 | ||
| 6482 | 12년 전 | 1345 | ||
| 6481 | 12년 전 | 1475 | ||
| 6480 |
Header
|
12년 전 | 692 | |
| 6479 |
|
12년 전 | 1130 | |
| 6478 |
개초보제이
|
12년 전 | 1396 | |
| 6477 | 12년 전 | 805 | ||
| 6476 | 12년 전 | 1077 | ||
| 6475 | 12년 전 | 3688 | ||
| 6474 | 12년 전 | 1431 | ||
| 6473 | 12년 전 | 963 | ||
| 6472 | 12년 전 | 859 | ||
| 6471 |
AMDbest
|
12년 전 | 1207 | |
| 6470 |
jinmuk
|
12년 전 | 1450 | |
| 6469 |
jinmuk
|
12년 전 | 4251 | |
| 6468 |
jinmuk
|
12년 전 | 5583 | |
| 6467 | 12년 전 | 708 | ||
| 6466 |
jinmuk
|
12년 전 | 2285 | |
| 6465 |
jinmuk
|
12년 전 | 6741 | |
| 6464 |
jinmuk
|
12년 전 | 2411 | |
| 6463 |
jinmuk
|
12년 전 | 9337 | |
| 6462 |
희망과열정
|
12년 전 | 542 | |
| 6461 |
Header
|
12년 전 | 728 | |
| 6460 |
희망과열정
|
12년 전 | 1364 | |
| 6459 |
프리랜서개발자
|
12년 전 | 1679 | |
| 6458 | 12년 전 | 1343 | ||
| 6457 |
jinmuk
|
12년 전 | 1953 | |
| 6456 |
jinmuk
|
12년 전 | 2352 | |
| 6455 |
jinmuk
|
12년 전 | 3213 | |
| 6454 |
jinmuk
|
12년 전 | 2179 | |
| 6453 |
jinmuk
|
12년 전 | 2364 | |
| 6452 |
jinmuk
|
12년 전 | 2320 | |
| 6451 |
jinmuk
|
12년 전 | 1615 | |
| 6450 |
jinmuk
|
12년 전 | 1404 | |
| 6449 |
jinmuk
|
12년 전 | 1049 | |
| 6448 |
jinmuk
|
12년 전 | 1252 | |
| 6447 |
jinmuk
|
12년 전 | 2015 | |
| 6446 |
jinmuk
|
12년 전 | 1575 | |
| 6445 |
jinmuk
|
12년 전 | 1266 | |
| 6444 |
jinmuk
|
12년 전 | 2316 | |
| 6443 |
jinmuk
|
12년 전 | 2049 | |
| 6442 |
jinmuk
|
12년 전 | 1895 | |
| 6441 |
jinmuk
|
12년 전 | 1626 | |
| 6440 |
jinmuk
|
12년 전 | 2325 | |
| 6439 |
jinmuk
|
12년 전 | 1140 | |
| 6438 |
wndProc
|
12년 전 | 789 | |
| 6437 | 12년 전 | 411 | ||
| 6436 |
senseme
|
12년 전 | 554 | |
| 6435 | 12년 전 | 1050 | ||
| 6434 | 12년 전 | 2485 | ||
| 6433 | 12년 전 | 2493 | ||
| 6432 | 12년 전 | 1567 | ||
| 6431 |
밥먹고합시다
|
12년 전 | 1194 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기