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

  • SEARCH
  • Home
  • 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 6874171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:09:41+00:00 2026-05-27T04:09:41+00:00

I have a string like this <InitParams> <myparams> <Ad>true</Ad> <Ay>true</Ay> <Sd>false</Sd> </myparams> <myContent> <Item>

  • 0

I have a string like this

<InitParams>
                <myparams>

                  <Ad>true</Ad>
                  <Ay>true</Ay>
                  <Sd>false</Sd>

                </myparams>
                <myContent>

                  <Item>
                      <IM>true</IM>
                      <AL>1234</AL>

                    </Item>

                </myContent>
              </InitParams>

I need the value between the tags <IM> and <AL>. Being new to C# and .net not sure what would be the best way to do it. Read up on xmlDoc and linq but sounds like overkill for this small need.

  • 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-27T04:09:42+00:00Added an answer on May 27, 2026 at 4:09 am

    The whole point of something like LINQ to XML was to prevent overkill, because it’s so easy to use:

        using System;
        using System.Collections.Generic;
        using System.IO;
        using System.Linq;
        using System.Xml.Linq;
    
    
    
     namespace WhateverNamespaceYouWant
     {
    
        public class Item
        {
            public bool IM { get; set; }
            public int AL { get; set; }
        }
        public class ItemsRepository
        {
            public IEnumerable<Item> GetAllItemsInXML()
            {
                var _items = new List<Item>();
                var doc = XDocument.Load("this");
                // finds every node of Item
                doc.Descendants("Item").ToList()
                .ForEach(item =>
                {
                    var myItem = new Item() // your domain type
                    {
                        IM = item.Element("IM").Value.ConvertToValueType<bool>(),
                        AL = item.Element("AL").Value.ConvertToValueType<int>(),
                    };
                    _items.Add(myItem);
                });
                return _items;
            }
        }
    
        public static class Extensions
        {
            public static T ConvertToValueType<T>(this string str) where T : struct
            {
                try
                {
                    return (T)Convert.ChangeType(str, typeof(T));
                }
                catch
                {
                    return default(T);
                }
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this that I need to parse into a 2D
I have a string like this: SELECT NOW(),DATE_ADD(NOW(), INTERVAL -11 day) and I need
I have a string like this ch:keyword ch:test ch:some_text I need a regular expression
I have a string like this: Please refer to document ABC.123.1234.1234 and document CBA.321.4321
I have a string like this: http://www.downlinegoldmine.com/viralmarketing I need to remove http://www. from the
i have a string like this : string_data = <option value='1'>ahmad</option><option value='2'>mohammad</option><option value='3'>ali</option> now
I have a String Like This: Dark Bronze - add $120.00 I need to
i have string like this: string = The stock item 28031 (111111: Test product)
i have a string like this.. /home/Abcd/Pradeep/Jack.sh /home/Abcd/Pradeep/Paul/Kill.sh I need to take Jack.sh and
I have a string like this: http://localhost:55164/Images/photos/2/2.jpg I need to retrieve the filename 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.