Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1040959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:17:21+00:00 2026-05-16T15:17:21+00:00

I’ve got a problem witch I’ve been trying to solve almost for a week

  • 0

I’ve got a problem witch I’ve been trying to solve almost for a week now, but it seems that, unfortunately, I can’t manage it by myself.
Maybe somebody could help me.

I’ve got this type of source XML:

<data> 
<para1>24499</para1> 
<para2>32080148</para2> 
<para4>20e500cc6008d0f8ab1fd108b220ca261f85edd9</para4> 
<para6></para6> 
<timetype>4</timetype> 
<fkcontent>964342</fkcontent> 
<season>0</season> 
<fmstoken><![CDATA[7bca3c544ad64e526806fb5a6b845148]]></fmstoken> 
<fmstoken_user>32010484</fmstoken_user> 
<fmstoken_time>1283165972</fmstoken_time> 
<fmstoken_renew><![CDATA[http://www.sky.com/logic/fmstoken.php?method=refresh]]></fmstoken_renew> 
<adserverXML><![CDATA[http://www.sky.de/dummy.xml]]></adserverXML> 
    <playlist> 
<videoinfo quality="0" name="DSL 1000"> 
    <id>24499</id> 
    <noad>1</noad> 
    <productplacement>0</productplacement> 
    <filename>http://www.sky.com/video/1/V_53511_BB00_E81016_46324_16x9-lq-512x288-vp6-c0_bbb491b3ce64ef667340a21e2bfb3594.f4v</filename> 
    <title><![CDATA[Who will be the winner?]]></title> 

    </videoinfo> 
<videoinfo quality="1" name="DSL 2000"> 
    <id>24499</id> 
    <noad>1</noad> 
    <productplacement>0</productplacement> 
    <filename>http://www.sky.de/video/1/V_53513_BB00_E81016_46324_16x9-hq-512x288-vp6-c0_fa948bc5429cf28455779666cc59cf5e.f4v</filename> 
    <title><![CDATA[Who will be the winner?]]></title> 

    </videoinfo> 
    </playlist> 
</data>

And here are parts of the code that let me get required tag content from xml page above:

        private static string getTagContent(string source, string tag)
    {
        string fullTagBegin = "<" + tag + ">";
        string fullTagEnd = "</" + tag + ">";

        int indexBegin = source.IndexOf(fullTagBegin) + fullTagBegin.Length;
        int indexEnd = source.IndexOf(fullTagEnd);
        int indexLength = indexEnd - indexBegin;

        if (indexBegin == -1 || indexEnd == -1)
            return "UNKNOWN";
        return source.Substring(indexBegin, indexLength);
    }



    public static void Start(String url)
    {
        try
        {
            String urlXML = url;
            WebClient wClient = new WebClient();

            string sourceXML = wClient.DownloadString(urlXML);
            sourceXML = sourceXML.Replace("]]>", "");
            sourceXML = sourceXML.Replace("<![CDATA[", "");


            String para1 = getTagContent(sourceXML, "para1");
            String para2 = getTagContent(sourceXML, "para2");
            String para4 = getTagContent(sourceXML, "para4");
            String timetype = getTagContent(sourceXML, "timetype");
            String fkcontent = getTagContent(sourceXML, "fkcontent");
            String season = getTagContent(sourceXML, "season");
            String fmstoken = getTagContent(sourceXML, "fmstoken");
            String fmstoken_user = getTagContent(sourceXML, "fmstoken_user");
            String fmstoken_time = getTagContent(sourceXML, "fmstoken_time");
            String fmstoken_renew = getTagContent(sourceXML, "fmstoken_renew");
            String filename = getTagContent(sourceXML, "filename").Replace("http://", "");
            String title = System.Text.RegularExpressions.Regex.Replace(getTagContent(sourceXML, "title"), @"[^a-zA-Z0-9]","_");

The problem is:

everything works fine except the fact, that there are two “filename” and “title” tags in the source xml, but I need to choose only second ones, those that are under this line:

<videoinfo quality="1" name="DSL 2000">,

and somehow skip/ignore first ones, those that are above previous line and right under this line:

<videoinfo quality="0" name="DSL 1000">

I can’t figure out how to do that.

(My only guess is that maybe it has something to do with XPathNavigator, but I’m not sure if that’s a right guess, and anyway, I don’t really understand how to use it properly).


Edit: problem solved.
I want to thank everyone who replied for your suggestions.
Really appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:17:21+00:00Added an answer on May 16, 2026 at 3:17 pm

    You should really load the XML into XMlDocument object and then edit it.
    But if you prefer to use your existing code, this dirty code should do the trick.

            int indexBegin = source.IndexOf(fullTagBegin) == source.LastIndexOf(fullTagBegin) ? source.IndexOf(fullTagBegin) + fullTagBegin.Length : source.LastIndexOf(fullTagBegin) + fullTagBegin.Length;
            int indexEnd = source.IndexOf(fullTagEnd) == source.LastIndexOf(fullTagEnd) ? source.IndexOf(fullTagEnd) : source.LastIndexOf(fullTagEnd);
    

    This will move the indexes to the last occurrence of whatever tag you’re looking for. Just replace your declarations with this ones.

    Edit: Additionally, you use this easy few lines to find/manipulate your XML in a much cleaner way.

            XmlDocument doc = new XmlDocument();
            doc.Load(filename);
            // or doc.LoadXML(fullXMLcode);
    
            var elements = doc.GetElementsByTagName("title");
            var element = elements.Item(elements.Count - 1); // returns the last element
            // element.InnerText gets the value you need. You can use this property to change it, too
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to solve this problem for over an hour now, and can't
I've got a rather tricky problem that I've been trying to solve for the
I've got a problem with inheritance and generics. This is the code that illustrates
I've got a problem here with an MSI deployment that I'm working on (using
I've got a strange problem with SQL Server 2000, and I just can't think
I'm onto problem 245 now but have hit some problems. I've done some work
It appears after much searching that there seems to be a common problem when
I'm trying to get some aggregate values from different tables, but my problem is
I'm trying to make an arkanoid-like game, and now I'm facing a problem with
I've been trying to get this javascript animation to work for hours now, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.