1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Asp xml read attributes

Discussion in 'C#' started by n971, Jul 26, 2007.

  1. #1
    Hi,

    XML:
    ...<Category><Action><Game ID="9"/><Game ID="17"/></Action><Puzzle><Game ID="57"/> etc

    I need to read and store ID attributes for every element (Action, Puzzle...). Just can't find a way to read this attributes in asp.

    TIA
     
    n971, Jul 26, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Not sure of the classic ASP approach but right off the top of my head you can always run regex to find all matches of your content pieces and manually parse them.

    Like Get all matches for "<Action>(.*)</Action>"
    Then get all matches for "<Game ID=(.*)/>" and replace the outer strings
    Dim GameMatchVal as string = Replace(GameMatch, "<Game ID=", "")
    GameMatchVal = Replace(GameMatch, "/>", "")

    In fact, i think you can get the "Grouped" object elements... so you can just extract whatever is between (.*)... but I'm not sure of the syntax off the otp of my head.
     
    ccoonen, Aug 2, 2007 IP
  3. n971

    n971 Well-Known Member

    Messages:
    236
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    123
    #3
    I fixed it already. Answer is so easy (as always)

    You do it like this:
    mystring=somenode.getAttribute("ID")
     
    n971, Aug 4, 2007 IP