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 989053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:43:50+00:00 2026-05-16T05:43:50+00:00

my xml is below: <Demo> <ClientCompanyId CompanyId=1> <MyMenu> <module MenuType=0 ModID=Mod1 ModuleID=1 Perm=False Text=Basic

  • 0

my xml is below:

<Demo>
    <ClientCompanyId CompanyId="1">
        <MyMenu>
            <module MenuType="0" ModID="Mod1" ModuleID="1" Perm="False" Text="Basic Settings">
                <menu MID="1-1" MenuDescription="Mod" MenuType="0" ModuleID="1" ParentID="Mod1" Perm="False" Text="Forms">
                    <Leaf LeafNode="true" MID="1-3" MenuDescription="" MenuType="0" ModuleID="1" ModuleMenuID="1-3" ParentID="1" Perm="False" TargetUrl="" Text="LookUp"/>
                    <submenu MID="1-4" MenuDescription="" MenuType="0" ModuleID="1" ParentID="1" Perm="False" Text="Bank Branch">
                        <Leaf LeafNode="true" MID="1-5" MenuDescription="" MenuType="0" ModuleID="1" ModuleMenuID="1-5" ParentID="4" Perm="False" TargetUrl="" Text="BO Category"/>
                    </submenu>
                </menu>
                <menu MID="1-2" MenuDescription="Mod" MenuType="0" ModuleID="1" ParentID="Mod1" Perm="False" Text="Reports">
                    <Leaf LeafNode="true" MID="1-6" MenuDescription="" MenuType="0" ModuleID="1" ModuleMenuID="1-6" ParentID="2" Perm="False" TargetUrl="" Text="Cheque Type"/>
                    <Leaf LeafNode="true" MID="1-7" MenuDescription="" MenuType="0" ModuleID="1" ModuleMenuID="1-7" ParentID="2" Perm="False" TargetUrl="" Text="Stock Exchange"/>
                </menu>
            </module>
        </MyMenu>
    </ClientCompanyId>
</Demo>

my linq syntax is below:

 XDocument loaded = XDocument.Load(@"C:\Menu_Settings.xml");
 var q = from c in loaded.Descendants("module")
 where (int)c.Attribute("ModuleID") < 0
 select (string)c.Attribute("Text");

From the above xml file i want to get tag attributes values.

Text="Basic Settings" ModID="Mod1" ModuleID="1" MenuType="0" Perm="False"

From the above xml i want to get all tag attributes values .

How to get value from an xml file?

  • 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-16T05:43:51+00:00Added an answer on May 16, 2026 at 5:43 am

    Or you can in the last step cast to XElement and use whatever XElement has to offer:

    instead of var q:

    IEnumerable<XElement> q =from c in loaded.Descendants("module") 
                        where (int)c.Attribute("ModuleID").Value < 0 
                        select c;
    
    foreach(XElement e in q){
       string t = e.Attribute("Text").Value;
       // etc...
    }
    

    if you know one record is going to be return

    XElement q = (from c in loaded.Descendants("module") 
                        where (int)c.Attribute("ModuleID").Value < 0 
                        select c).First(); // one of many options to return a single record
    
    sring t = q.Attribute("Text").Value;
    // etc...
    

    UPDATE

    to make further queries to your result:

    IEnumarble<XElement> menus = q.Elements("menu");
    

    then loop foreach, you can use menuselement.Element("tag_name").Value to get string values of the nodes, or menuselement.Attribute("attr_name").Value to get attribute values, and you can further query with menuslement.Find or menuselement.Where or menuselement.Select and the options are really limitless… here is where you can learn more:
    http://msdn.microsoft.com/en-us/library/bb387065.aspx

    And here is MSDN’s how to query xml using linq:
    http://msdn.microsoft.com/en-us/library/bb943906.aspx

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

Sidebar

Related Questions

Below is a demo SOAP request message: HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length:
If you have the xml below in $(xml), you would get droopy using: $(xml).find(animal).find(dog).find(beagle).text()
I have the xml below that I've pasted here with this rule: /bookstore/book/price/text() <?xml
With the XML below, I would like to know how to get the value
Given the XML below, I need to group by InputItem and sum the costs
From the XML below I'm trying to retrieve the second element in the sequence.
I need to generate an xsl table for the xml below, for attributes fname
I'm trying to extract the StateLongName and StateShortName values from the xml below. I
the xml version below properly handles height and width and the java doesn't what
I have a xml given below: <root title=الصفحة الرئيسة> <item title=الصفحة الرئيسة itemuri=tcm:8-29-4 ShowInNav=True

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.