이 기사에 제공된 예는 HTML 형식 데이터를 XML로 저장하는 것과 유사합니다. 과거에는 양식이 제출되면 일반적으로 새 문서를 만들었습니다. 이제는 문서가 이미 존재하는 한 직접 추가할 수 있습니다. 이 기술의 사용은 기본 데이터를 생성하는 것과 유사합니다.
이전 기사에서는 XMLDOM을 사용하는 방법을 설명했습니다. 그럼 바로 이 글의 예시로 넘어가겠습니다.
가장 먼저 고려해야 할 것은 새 "레코드"를 추가하는 데 사용할 HTML 형식입니다. "HTML 양식 데이터를 XML로 저장" 예제에서는 이미 이 양식을 사용했으며 파일 이름만 변경했지만 코드는 동일합니다.
AddContact.html:
<html> <head> <title> Contact Information </title> </head> <body> <form action="processAdd.asp" method="post"> <h3 id="Enter-nbsp-your-nbsp-contact-nbsp-information">Enter your contact information</h3> First Name: <input type="text" id="firstName" name="firstName"><br> Last Name: <input type="text" id="lastName" name="lastName"><br> Address #1: <input type="text" id="address1" name="address1"><br> Address #2: <input type="text" id="address2" name="address2"><br> Phone Number: <input type="text" id="phone" name="phone"><br> E-Mail: <input type="text" id="email" name="email"><br> <input type="submit" id="btnSub" name="btnSub" value="Submit"><br> </form> </body> </html>
ADD를 처리하기 위해 이 HTML 양식을 설정했습니다. ASP. 여기 ASP 페이지에는 XML 파일과 ROLODEX.XML이 존재하는지 감지하는 기능이 있습니다. 파일이 있으면 ASP는 파일에 새 항목을 추가하고, 파일이 없으면 파일을 만들어야 합니다.
프로세스 Add.asp:
<% '-------------------------------------------------------------------- 'The "addNewContacttoXML" Function accepts two parameters. 'strXMLFilePath - The physical path where the XML file will be saved. 'strFileName - The name of the XML file that will be saved. '-------------------------------------------------------------------- Function addNewContacttoXML(strXMLFilePath, strFileName) 'Declare local variables. Dim objDom Dim objRoot Dim objRecord Dim objField Dim objFieldValue Dim objattID Dim objattTabOrder Dim objPI Dim blnFileExists Dim x 'Instantiate the Microsoft XMLDOM. Set objDom = server.CreateObject("Microsoft.XMLDOM") objDom.preserveWhiteSpace = True 'Call the Load Method of the XMLDOM Object. The Load ethod has a 'boolean return value indicating whether or not the file could be 'loaded. If the file exists and loads it will return true, otherwise, 'it will return false. blnFileExists = objDom.Load(strXMLFilePath & "\" & strFileName) 'Test to see if the file loaded successfully. If blnFileExists = True Then 'If the file loaded set the objRoot Object equal to the root element 'of the XML document. Set objRoot = objDom.documentElement Else 'Create your root element and append it to the XML document. Set objRoot = objDom.createElement("rolodex") objDom.appendChild objRoot End If 'Create the new container element for the new record. Set objRecord = objDom.createElement("contact") objRoot.appendChild objRecord 'Iterate through the Form Collection of the Request Object. For x = 1 To Request.Form.Count 'Check to see if "btn" is in the name of the form element. If it is, 'then it is a button and we do not want to add it to the XML 'document". If instr(1,Request.Form.Key(x),"btn") = 0 Then 'Create an element, "field". Set objField = objDom.createElement("field") 'Create an attribute, "id". Set objattID = objDom.createAttribute("id") 'Set the value of the id attribute equal the the name of the current 'form field. objattID.Text = Request.Form.Key(x) 'The setAttributeNode method will append the id attribute to the 'field element. objField.setAttributeNode objattID 'Create another attribute, "taborder". This just orders the 'elements. Set objattTabOrder = objDom.createAttribute("taborder") 'Set the value of the taborder attribute. objattTabOrder.Text = x 'Append the taborder attribute to the field element. 'objField.setAttributeNode objattTabOrder 'Create a new element, "field_value". Set objFieldValue = objDom.createElement("field_value") 'Set the value of the field_value element equal to the value of the 'current field in the Form Collection. objFieldValue.Text = Request.Form(x) 'Append the field element as a child of the new record container 'element, contact. objRecord.appendChild objField 'Append the field_value element as a child of the field element. objField.appendChild objFieldValue End If Next 'Check once again to see if the file loaded successfully. If it did 'not, that means we are creating a new document and need to be sure to 'insert the XML processing instruction. If blnFileExists = False then 'Create the xml processing instruction. Set objPI = objDom.createProcessingInstruction("xml", "version='1.0'") 'Append the processing instruction to the XML document. objDom.insertBefore objPI, objDom.childNodes(0) End If 'Save the XML document. objDom.save strXMLFilePath & "\" & strFileName 'Release all of your object references. Set objDom = Nothing Set objRoot = Nothing Set objRecord = Nothing Set objField = Nothing Set objFieldValue = Nothing Set objattID = Nothing Set objattTabOrder = Nothing Set objPI = NothingEnd Function 'Do not break on an error. On Error Resume Next 'Call the addNewContacttoXML function, passing in the physical path to 'save the file to and the name that you wish to use for the file. addNewContacttoXML "c:","rolodex.xml" 'Test to see if an error occurred, if so, let the user know. 'Otherwise, tell the user that the operation was successful. If err.number <> 0 then Response.write("Errors occurred while saving your form submission.") Else Response.write("Your form submission has been saved.") End If %>
"HTML 양식 데이터를 XML 형식으로 저장"에 대한 기사를 읽었다면 HTML 데이터 확장에 추가되는 것을 알 수 있습니다. XML 파일에 대한 코드는 기본적으로 HTML 데이터를 새 문서로 확장하는 코드와 동일합니다. 그러나 여기에는 두 가지 주요 차이점이 있습니다.
'Call the Load Method of the XMLDOM Object. The Load Method has a 'boolean return value indicating whether or not the file could be 'loaded. If the file exists and loads it will return true, otherwise, 'it will return false. blnFileExists = objDom.Load(strXMLFilePath & "\" & strFileName) 'Test to see if the file loaded successfully. If blnFileExists = True Then 'If the file loaded set the objRoot Object equal to the root element 'of the XML document. Set objRoot = objDom.documentElement Else 'Create your root element and append it to the XML document. Set objRoot = objDom.createElement("contact") objDom.appendChild objRoot End If
이 섹션의 코드는 addNewContacttoXML 함수에서 가져온 것입니다. 매번 새 파일을 만들 수 없기 때문에 대신 CONTACT를 저장합니다. 파일을 로드할 수 있으면 XML 문서의 루트 요소를 가져옵니다. 그렇지 않으면 해당 요소가 존재하지 않는다고 가정하고 새 요소를 만들어 XML 문서에 추가합니다.
또 다른 주요 차이점은 LOAD가 성공했는지 확인하기 위해 파일에 대한 2차 검사를 수행할 때 처리 명령을 추가해야 하는지 여부를 결정할 수 있다는 것입니다. 파일이 존재하는 경우 이 지시어를 추가할 필요가 없습니다. 단, 새로운 파일이 생성되는 경우에는 이 처리 명령을 추가해야 합니다.
'Check once again to see if the file loaded successfully. If it did 'not, that means we are creating a new document and need to be sure to 'insert the XML processing instruction. If blnFileExists = False then 'Create the xml processing instruction. Set objPI = objDom.createProcessingInstruction("xml", "version='1.0'") 'Append the processing instruction to the XML document. objDom.insertBefore objPI, objDom.childNodes(0) End If
위의 두 가지 차이점 외에도 새 파일에 데이터를 저장하는 코드는 실제로 새 레코드를 추가하는 코드와 동일하다는 것을 알 수 있습니다. 기존 파일. 새로 추가된 각 RECORD를 수용하기 위해 CONTAINER라는 새 요소를 만듭니다. 코드는 요청 개체의 양식 컬렉션에서 반복되어 적절한 XML 노드를 생성하고 노드 값을 현재 양식 필드와 동일하게 설정합니다.
위는 XML 문서에 새로운 "기록"을 추가하는 내용입니다. 더 많은 관련 내용은 PHP 중국어 홈페이지(www.php.cn)를 참고해주세요!

RSS는 자주 업데이트되는 컨텐츠를 게시하는 데 사용되는 XML 기반 형식입니다. 1. RSSFEED는 제목, 링크, 설명 등을 포함하여 XML 구조를 통해 정보를 구성합니다. 2. RSSFEED를 만들려면 XML 구조로 작성하고 언어 및 출시 날짜와 같은 메타 데이터를 추가해야합니다. 3. 고급 사용에는 멀티미디어 파일과 분류 된 정보가 포함될 수 있습니다. 4. 디버깅 중 XML 검증 도구를 사용하여 필요한 요소가 존재하고 올바르게 인코딩되도록하십시오. 5. RSSFEED 최적화는 구조를 단순하게 유지하고 페이징, 캐싱 및 유지함으로써 달성 할 수 있습니다. 이 지식을 이해하고 적용함으로써 컨텐츠를 효과적으로 관리하고 배포 할 수 있습니다.

RSS는 컨텐츠를 게시하고 구독하는 데 사용되는 XML 기반 형식입니다. RSS 파일의 XML 구조에는 컨텐츠 항목을 나타내는 루트 요소, 요소 및 여러 요소가 포함됩니다. XML Parser를 통해 RSS 파일을 읽고 구문 분석하고 사용자는 최신 컨텐츠를 구독하고 얻을 수 있습니다.

XML은 RSS에서 구조화 된 데이터, 확장 성, 크로스 플랫폼 호환성 및 구문 분석 검증의 장점을 가지고 있습니다. 1) 구조화 된 데이터는 컨텐츠의 일관성과 신뢰성을 보장합니다. 2) 확장 성은 콘텐츠 요구에 맞게 맞춤형 태그를 추가 할 수 있습니다. 3) 크로스 플랫폼 호환성은 다른 장치에서 원활하게 작동합니다. 4) 분석 및 검증 도구는 피드의 품질과 무결성을 보장합니다.

XML에서 RSS 구현은 구조화 된 XML 형식을 통해 컨텐츠를 구성하는 것입니다. 1) RSS는 채널 정보 및 프로젝트 목록과 같은 요소를 포함하여 XML을 데이터 교환 형식으로 사용합니다. 2) RSS 파일을 생성 할 때는 사양에 따라 컨텐츠를 구성하고 구독을 위해 서버에 게시해야합니다. 3) RSS 파일은 리더 또는 플러그인을 통해 구독하여 컨텐츠를 자동으로 업데이트 할 수 있습니다.

RSS의 고급 기능에는 컨텐츠 네임 스페이스, 확장 모듈 및 조건부 구독이 포함됩니다. 1) 컨텐츠 네임 스페이스는 RSS 기능을 확장합니다. 2) 메타 데이터를 추가하기 위해 Dublincore 또는 iTunes와 같은 확장 된 모듈, 3) 특정 조건에 따라 조건부 구독 필터 항목. 이러한 기능은 XML 요소 및 속성을 추가하여 정보 수집 효율성을 향상시켜 구현됩니다.

rssfeedsusexmltostructurecontentupdates.1) xmlprovideahierarchicalstructurefordata.2) the ElementDefinesThefeed 'sidentityandContainsElements.3) elementsreent indindividualcontentpieces.4) rssisextensible, 허용 Bestpracticesin

RSS 및 XML은 웹 컨텐츠 관리를위한 도구입니다. RSS는 컨텐츠를 게시하고 구독하는 데 사용되며 XML은 데이터를 저장하고 전송하는 데 사용됩니다. 컨텐츠 게시, 구독 및 업데이트 푸시와 함께 작동합니다. 사용의 예로는 RSS 게시 블로그 게시물 및 XML 저장 도서 정보가 있습니다.

RSS 문서는 자주 업데이트되는 콘텐츠를 게시하고 구독하는 데 사용되는 XML 기반 구조 파일입니다. 주요 기능에는 1) 자동화 된 컨텐츠 업데이트, 2) 컨텐츠 집계 및 3) 브라우징 효율 향상이 포함됩니다. RSSFEED를 통해 사용자는 적시에 다른 소스에서 최신 정보를 구독하고 얻을 수 있습니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기
