Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    57

    Question Unanswered: XMLQUERY wildcard

    Hi experts!

    I'm making a XMLQuery but i've got an issue, i need to get a value but comes in 2 differents tags, it depends from which XML comes, example:
    XML1:
    HTML Code:
    <tag1>
        <Actor>User1</Actor>
    </tag1>
    XML2:
    HTML Code:
    <tag1>
        <Actor_new>User1</Actor_new>
    </tag1>
    and to get it i use 2 differents XMLQuery:

    Code:
    select xmlcast(xmlquery ('$XML_campo//tag1/Actor) as char(12))  from Table
    or

    Code:
    select xmlcast(xmlquery ('$XML_campo//tag1/Actor_new) as char(12))  from Table
    I'm looking the way to use a wildcard like: % or ? or ...., etc in the XMLQuery, instead to use 2 differents querys. Is there anyway to make this?

    Best regards!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    It's not about XMLquery, it's how XPath works. There are no wildcards, but you can try something like
    Code:
    xmlquery ('$XML_campo//tag1/Actor|//tag1/Actor_new|')
    Note, however, that this will return a sequence, not a single element, so I'm afraid you won't be able to cast it to char(12).
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Sep 2011
    Posts
    57
    ok, let me look for something like that.
    Thanks

  4. #4
    Join Date
    Sep 2011
    Posts
    57
    ok, you are rigth it really works:

    xmlquery ('$XML_campo//tag1/Actor|$XML_campo//tag1/Actor_new')

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •