본문 바로가기
Web Program/Asp Lecture

정규식으로 xml 데이타 읽기

by 현이빈이 2008. 9. 8.
반응형
XML 문서가 아닌 일반문서에서도 적용가능한 정규식으로 한번 풀어봤습니다.

정규식에 관한 건 검색하시면 부지기수이구요. ^^*


아래 소스 ASP 파일로 저장해서 돌려보신 후 마음에 드시면 정규식 관련 글들을 읽어보시기 바랍니다.

**********************************************************************************************

<%


    xmlData = Request.Form("xmlData")


    If xmlData <> "" then

        Set objRegExp = New RegExp


        objRegExp.Pattern = "ScreenSize>[^<]*"

        Set arrScreenSize = objRegExp.Execute(xmlData)


        For Each ScreenSize In arrScreenSize

            Response.Write "ScreenSize : " & Replace(ScreenSize.value, "ScreenSize>", "") & "<br>"

        Next


        objRegExp.Pattern = "SoftwareScreenSize>[^<]*"

        Set arrSoftwareScreenSize = objRegExp.Execute(xmlData)


        For Each SoftwareScreenSize In arrSoftwareScreenSize

            Response.Write "SoftwareScreenSize : " & Replace(SoftwareScreenSize.value, "SoftwareScreenSize>", "") & "<br>"

        Next

    End if

%>



<FORM METHOD="POST">

<TEXTAREA NAME="xmlData" style="width: 100%; height: 400px;">

    <rdf:RDF xmlns:ccpp="http://www.w3.org/2002/11/08-ccpp-schema#"         xmlns:mms="http://www.wapforum.org/profiles/MMS/ccppschema-20010111#"         xmlns:prf="http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20030226#"         xmlns:prfext="http://mobileinternet.nate.com/tech/rdf/profiles/UAPROF/ccppschema-20030811#"         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

    <rdf:Description rdf:ID="N_SSD8">

    <prf:component>

        <rdf:Description ID="HardwarePlatform">

        <rdf:type rdf:resource="http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20030226#HardwarePlatform"/>

        <prf:ScreenSize>240x320</prf:ScreenSize>

        </rdf:Description>

    </prf:component>

    <prf:component>

        <rdf:Description ID="SoftwarePlatform">

        <rdf:type rdf:resource="http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20030226#SoftwarePlatform"/>

        <prfext:SoftwareScreenSize>240x297</prfext:SoftwareScreenSize>

        </rdf:Description>

        </prf:component>

    </rdf:Description>

    </rdf:RDF>

</TEXTAREA>

<INPUT TYPE="submit">

</FORM>

반응형