[ 파워빌더.공통함수 - xmlParser ]
☞ Xml 을 읽는 예제.. Xml Parsing .. MS XML Parser (PB 9 이전 버전서 유용할 듯) |
|
제가 예전에 PBDN에 올렸었던 자료입니다..
MsXML 을 이용하여 xml을 읽는 예제입니다..
파빌 9버전 이전 버전은 유용할 듯...하네요..
소스 참조 하세요..
oleobject xmldoc, root, rootlist, rootnode, childlist, childnode Integer li_rc, i, j Boolean lb_test string ls_file
//객체를 만들고 xmldoc = Create oleobject li_rc = xmldoc.ConnectToNewObject("MSXML2.DOMDocument.3.0") IF li_rc < 0 THEN fmsg("Connecting to COM Object Failed", "Error: " + String(li_rc)) DESTROY xmldoc Return END IF
//파일을 연결하고 ls_file = "D:\Z_Work\book.xml" lb_test=xmldoc.load(ls_file) IF lb_test = false THEN //Demonstrate the parseError attribute fmsg("Load of XML doc Failed", "ErrorCode: "+string(xmldoc.parseError.ErrorCode)+ "~n~r" & + "FilePosition: " +string(xmldoc.parseError.Filepos)+ "~n~r" & + "Line: " +string(xmldoc.parseError.Line)+ "~n~r" & + "LinePosition: " +string(xmldoc.parseError.Linepos)+ "~n~r" & + "Reason: " +string(xmldoc.parseError.Reason)+ "~n~r" & + "SourceText: " +string(xmldoc.parseError.SrcText)) DESTROY xmldoc Return END IF
//내용을 읽고 root = xmlDoc.documentElement rootlist = root.childnodes For i = 0 To rootlist.length - 1 rootnode= rootlist.item[i] childlist = rootnode.childnodes mle_1.text += string(i) +"~r~n"
For j = 0 To childlist.length -1 childnode = childlist.item[j] mle_1.text += string(i) + "." + string(j) + " : " + childnode.text + "~r~n" Next mle_1.text += "~r~n" Next
//oleobject xmldoc, root,rootlist, rootnode, child, childnode If IsValid(xmldoc) Then DESTROY xmldoc If IsValid(root) Then DESTROY root If IsValid(rootlist) Then DESTROY rootlist If IsValid(rootnode) Then DESTROY rootnode If IsValid(childlist) Then DESTROY childlist If IsValid(childnode) Then DESTROY childnode
|