parse a string using a delimeter in xml

Posted on 2011-04-27
Last Modified: 2012-05-11

I'm a newbie to web programming and I'm sure glad I found this site.

I have a string which I want to parse into 4 segments using a dash "-" as a delimeter.  Here is a sample data element:  ItemUpdate-HOSP-99998-C.  My data is contained in an xml string:  <!qry_wfw_WORK_TITLE>.  I know how to parse the xml string using a substring function; example <!qry_wfw_WORK_TITLE.substr(16, 5)> returns "99998".  How would I split the data into 4 different fields using a dash as a delimeter?  In other tools I would use a split function such as lsplt([field name], 4, "-", 3) where the function uses the delimeter "-" and returns the 3rd segment.
Question by:jrbledsoe001
    LVL 75

    Expert Comment

    by:Michel Plungjan

    It is not clear to me what language you are using and where.

    Is it inside XSL? because your syntax does not seems to match anything I have seen - like this for example
    LVL 35

    Accepted Solution

    Use string split method:
    string data = "qry_wfw_WORK_TITLE"; //your xml data to split
    string[] words = data.Split('_');
    //words[3] will contain title.

    Author Comment

    Hello mas oz2003!  I saw your reference to that url when I was researching my question.  Your comment information was all that I needed to understand how to use the string split method.  
    I think this split method will work perfectly.  Thanks for providing an answer to my question!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now