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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:21:24+00:00 2026-06-09T21:21:24+00:00

I have an XML-like file that has lines that look like this: <siteMapNode title=Our

  • 0

I have an XML-like file that has lines that look like this:

<siteMapNode title="Our Clients" url="~/OurClients">
    <siteMapNode title="Website Portfolio" url="~/OurClients/Portfolio" />
    <siteMapNode title="Testimonials" url="~/OurClients/Testimonials" />
</siteMapNode>

<siteMapNode title="Contact" url="~/Contact" />
<siteMapNode title="" url="~/Pharmacy" />
<siteMapNode url="~/ClinicWebsiteDevelopment" />
<siteMapNode url="~/HospitalWebsiteDevelopment" />

Notice how most of lines have a title attribute? What I want to do is use RegEx to capture all elements that do NOT have a title attribute AND I want to capture all lines that have an empty title attribute title="". So after running my example here through the RegEx, it should return me my last three lines, since the last two lines have no title attribute and the line before that has an empty title attribute.

Can someone please help me out on created this RegEx? This is for .NET by the way.

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-09T21:21:25+00:00Added an answer on June 9, 2026 at 9:21 pm

    You can do this easily with Linq2XML if you’re willing to add a bogus root element (assuming there is none):

    string foo = @"<bogus><siteMapNode title='Our Clients' url='~/OurClients'>
                    <siteMapNode title='Website Portfolio' url='~/OurClients/Portfolio' />
                    <siteMapNode title='Testimonials' url='~/OurClients/Testimonials' />
                    </siteMapNode>
    
                <siteMapNode title='Contact' url='~/Contact' />
                <siteMapNode title='' url='~/Pharmacy' />
                <siteMapNode url='~/ClinicWebsiteDevelopment' />
                <siteMapNode url='~/HospitalWebsiteDevelopment' /></bogus>";
    
    
    XDocument doc = XDocument.Parse(foo);
    
    var elements = doc.Root.Elements("siteMapNode");
    foreach (var elem in elements) {
        if (elem.Attribute("title") == null)
            Console.WriteLine("This one doesn't have the attribute!");
    }
    

    No need to use regular expressions. Regexen should never be used to parse markup. Even if your document is in a format that is not valid XML, it can still be parsed so long as you can extract fragments from it. Honestly I think this is a better/faster/simpler way to go about it.

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

Sidebar

Related Questions

I have an XML file that has a set of entries like this: <attr
I have an xml file that has an address node that looks like <address>
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return
--edited for clarity (hopefully) I have an XML file that looks something like this:
I have a large xml file that looks like this: 20120124 07:30:15.301, saving to
I have an XML File that looks like this: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
I have a method that has many many statements like this: employee.LastName = file.EMPLOYEE.NAME.SUBNAME.FAMILYNAME.NAMEPART1.Value;
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1

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.