Announcement

Collapse
No announcement yet.

ASP VB XML string extraction

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ASP VB XML string extraction

    Guys,

    Wondering if anyone can help, I have an XML string which is returned from DB, and I would like to extract all the information for a single node, with tag points <SELECTIONSUMMARY> and </SELECTIONSUMMARY>

    I know sod all about XML so have taken to the task treating this as a standard string using standard string manipulation.

    This is the code I have in my page

    Code:
     
    <% 
    sTemp = Recordset1.Fields.Item("JobResults").Value
    sNew = Mid(sTemp, InStr(sTemp, "<SELECTIONSUMMARY>")+18, InStrRev (sTemp, "</SELECTIONSUMMARY>"))
    response.Write(sNew)
    %>
    I can get the start point correct and the text displayed starts at the correct point but I cannot get it to "cut off" all text after the closing tag. I have tried different variants using Len(sTemp) - InStrRev, but no difference.

    Any Ideas ?

    Cheers
    Topper
    * Shamelessly mentioning "Don't forget to add reputation!"

  • #2
    Change sNew = Mid(sTemp, InStr(sTemp, "<SELECTIONSUMMARY>")+18, InStrRev (sTemp, "</SELECTIONSUMMARY>"))

    To

    sNew = Mid(stemp, InStr(sTemp, "<SELECTIONSUMMARY>")+18, (InStrRev (sTemp, "</SELECTIONSUMMARY>")) - (InStr(sTemp, "<SELECTIONSUMMARY>")+18 ))

    that will work.
    MCSE 2000\2003, A+
    00000001-00000011-00000011-00000111

    Comment


    • #3
      Why limit it to specific strings and/to their length???

      why not use something like this:

      Code:
      <%
      strStartTag = "<SomeTag>"
      strCloseTag = "</SomeTag>"
      strAllString = strStartTag & "Some Values I need" & strCloseTag
      
      strNew = Mid(strAllString,(InStr(strAllString,strStartTag)+Len(strStartTag)),InStr(strAllString,strCloseTag)-Len(strCloseTag))
      
      Response.Write strNew
      %>
      Hope this helps...
      Martin77

      Comment


      • #4
        Perfect !!

        Cheers pcking999

        ...........I love this forum !
        * Shamelessly mentioning "Don't forget to add reputation!"

        Comment


        • #5
          Originally posted by martin77
          Why limit it to specific strings and/to their length???
          Because that's all I need. Ever heard the anagram KIS ?

          Thanks for the reply though Martin, havn't tried it but it looks like it will work a treat.

          topper
          * Shamelessly mentioning "Don't forget to add reputation!"

          Comment

          Working...
          X