문제

나는 새로운 asp 고 마감 시한에서는 다음 몇 일입니다.나는 다음과 같은 xml 내에서 웹 서비스에 응답합니다.

print("<?xml version="1.0" encoding="UTF-8"?>
<user_data>
<execution_status>0</execution_status>
<row_count>1</row_count>
<txn_id>stuetd678</txn_id>
<person_info>
    <attribute name="firstname">john</attribute>
    <attribute name="lastname">doe</attribute>
    <attribute name="emailaddress">john.doe@johnmail.com</attribute>
</person_info>
</user_data>");

할 수 있는 방법 이러한 xml 구문 분석으로 asp 가?

어떤 도움을 크게 감사

감사 Damien

에서 더 많은 분석,몇몇 비누 물건은 또한 반환로 aboce 응답이 웹 서비스에서 호출합니다.계속 사용할 수 있습니까 존 코드는 아래?

도움이 되었습니까?

해결책

을 읽을 필요가에 대해 MSXML parser.다음 링크를 사용하면 좋은 하나로 모든 예 http://oreilly.com/pub/h/466

일부에 읽 XPath 로 도움이 될 것입니다.을 얻을 수 있는 데 필요한 모든 정보에 MSDN.

을 훔치는 코드 누가복음 우수한 답변을 집계를 위한 목적으로:

Dim oXML, oNode, sKey, sValue

Set oXML = Server.CreateObject("MSXML2.DomDocument.6.0") 'creating the parser object
oXML.LoadXML(sXML) 'loading the XML from the string

For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
  sKey = oNode.GetAttribute("name")
  sValue = oNode.Text
  Select Case sKey
    Case "execution_status"
    ... 'do something with the tag value
    Case else
    ... 'unknown tag
  End Select
Next

Set oXML = Nothing

다른 팁

ASP 에 의해 나는 가정을 의미 클래식 ASP?Try:

Dim oXML, oNode, sKey, sValue

Set oXML = Server.CreateObject("MSXML2.DomDocument.4.0")
oXML.LoadXML(sXML)

For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
  sKey = oNode.GetAttribute("name")
  sValue = oNode.Text
  ' Do something with these values here
Next

Set oXML = Nothing

위 코드에서 당신은 당신의 XML 라는 변수에 sXML.만약 당신이 이를 통해 ServerXMLHttp 요청해야 합를 사용할 수 있 ResponseXML 속에서 개체의 oXML 위에 건너뛰 LoadXML 단계니다.

당신이 시도할 수 있습 로드 xml 로 xmldocument 체 및 다음 분석을 사용하여 그것은 그것의 방법이 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top