컴퓨터 과학에서 파싱((syntactic) parsing)은 일련의 문자열을 의미있는 토큰(token)으로 분해하고 이들로 이루어진 파스 트리(parse tree)를 만드는 과정을 말한다.
XML이란 ?
XML은 W3C에서 개발된, 다른 특수한 목적을 갖는 마크업 언어를 만드는데 사용하도록 권장하는 다목적 마크업 언어이다.
XML Syntax Rules
XML documents must contain one root element that is the parent of all other elements:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
하나의 루트 엘레멘트가 반드시 있어야함.
<?xml version="1.0" encoding="UTF-8"?>
The XML prolog is optional. If it exists, it must come first in the document.
문서에서 가져오려면 위의 prolog가 있어야함
Elements vs Attributes
There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data.
ex)
<person sex="female">
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
<person>
<sex>female</sex>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
클라이언트에서
String 값을 보낼건데 XML형식에 맞췄다.
서버에서
받아온 값을 getElementByTagName(" ")으로 이름을 찾아서 받아온 값은 nodeList
같은 이름의 Element가 여러 개 있을 수 있다. nodeList에서 첫번째 element을 .item(0)으로 불러온다.
getTextContent로 element의 Text값을 불러온다.
출처
XML Tutorial
XML Tutorial XML stands for eXtensible Markup Language. XML was designed to store and transport data. XML was designed to be both human- and machine-readable. XML Example 2 Belgian
www.w3schools.com
XML - 위키백과, 우리 모두의 백과사전
위키백과, 우리 모두의 백과사전. XML(Extensible Markup Language)은 W3C에서 개발된, 다른 특수한 목적을 갖는 마크업 언어를 만드는데 사용하도록 권장하는 다목적 마크업 언어이다. XML은 SGML의 단순화
ko.wikipedia.org
ko.wikipedia.org/wiki/%EA%B5%AC%EB%AC%B8_%EB%B6%84%EC%84%9D
구문 분석 - 위키백과, 우리 모두의 백과사전
위키백과, 우리 모두의 백과사전.
ko.wikipedia.org
'Java > xml' 카테고리의 다른 글
JAXB example (0) | 2021.01.21 |
---|---|
JAXB 환경 설정 (0) | 2021.01.19 |
XML Schema로 java class 생성 (0) | 2021.01.19 |
XML Schema (0) | 2021.01.19 |
Xpath를 이용한 XML 파싱 (0) | 2021.01.19 |