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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:53:56+00:00 2026-06-03T23:53:56+00:00

I have unusual format of XML as below example <mainmenu> <menu caption=File> <menuitem caption=New

  • 0

I have unusual format of XML as below example

<mainmenu>
    <menu caption="File">
        <menuitem caption="New" tooltip="Create New File" shortcut="Ctrl-N" Action="New">
        <menuitem caption="Open" tooltip="Open Existing File" shortcut="Ctrl-O" Action="Open">
        <menu caption="Import">
            <menuitem caption="As New File" tooltip="Import To New Sheet" shortcut="F11" Action="ImportNew">
            <menuitem caption="As Current File" tooltip="Import To Current Active Sheet" shortcut="F12" Action="ImportOpen">
        </menu>
        <menuitem caption="Exit" tooltip="Exit Program" shortcut="Ctrl-Q" Action="Exit">
    </menu>
    <menu caption="Edit">
        <menuitem caption="Cut" tooltip="" shortcut="Ctrl-C" Action="Cut">
        <menuitem caption="Copy" tooltip="" shortcut="Ctrl-X" Action="Copy">
        <menuitem caption="Paste" tooltip="" shortcut="Ctrl-V" Action="Paste">
    </menu>
</mainmenu>

I need above XML to be parsed into tabular data view with dataset and then can be retrieved from a function, for example:

getData("Edit")

result:

caption tooltip shortcut action
cut     ...
copy    ...
paste   ...

Another example

getData("File.Import")

result:

caption         tooltip shortcut action
as new file     ...
as current file ...

So, what is the best method to parse the XML? Thanks.

  • 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-06-03T23:53:58+00:00Added an answer on June 3, 2026 at 11:53 pm

    Linq to Xml would be a good way to go for this. You can select menu elements based on the criteria, then select a collection of whatever data type you need based on the attributes of the menuitem elements. I wrote out an example below, which implements the simple example getData(“Edit”) and populates a DataTable with the child menu items (in your example, Cut, Copy, Paste).

    Dim xdoc As XDocument
    Dim filename As string    // TODO set XML filename
    Dim name As String
    Dim dt as DataTable
    xdoc = XDocument.Load(filename)
    name = "Edit"
    dt = New DataTable()
    
    xdoc.Root.Elements().Where(Function(s) s.Attribute("caption") = name).Elements("menuitem").ToList(). _
        ForEach(dt.Rows.Add(x.Attribute("caption"), x.Attribute("tooltip"), x.Attribute("shortcut"), x.Attribute("action")))
    

    It should be possible to extend this approach to select nested menu items based on “File.Import”, etc, as required.

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

Sidebar

Related Questions

i have an really unusual problem i've never had before. i've no .htaccess file
Hello I have an unusual date format that I would like to parse into
I have an unusual request. I've just moved to a new apartment and I
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have a large sparse matrix representing attributes for millions of entities. For example,
I have an unusual situation - I have an embedded video streaming device with
I have a rather unusual problem, and it is hurting my brain. Problem: Given
I have an idea for a pretty unusual alarm clock fir the iPhone. But
This is maybe unusual so let me set the scene: We have an SVN
I received a somewhat unusual request (imo) for a transactional web site. I have

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.