Community
    • Login

    URL to XML Structure

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.6k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      LordFader
      last edited by

      Hello all,

      for my sitemap.xml the URLs are available individually:
      (the URLs are shortened because otherwise I can not post)
      myurl com/ski-germany/topic-xyz
      myurl com/ski-france/topic-xyz
      myurl com/ski-swiss/topic-xyz
      …

      Now I want to bring them into this format:

      <url>
      <loc>myurl com/ski-germany/topic-xyz</loc>
      <lastmod>2023-09-12T15:00:00+00:00</lastmod>
      <changefreq>weekly</changefreq>
      </url>
      <url>
      <loc>myurl com/ski-france/topic-xyz</loc>
      <lastmod>2023-09-12T15:00:00+00:00</lastmod>
      <changefreq>weekly</changefreq>
      </url>
      <url>
      <loc>myurl com/ski-swiss/topic-xyz</loc>
      <lastmod>2023-09-12T15:00:00+00:00</lastmod>
      <changefreq>weekly</changefreq>
      </url>

      I can add <loc> etc but I can’t get it to work in that form, I’ve tried a few things. Can anyone do it?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Online
        PeterJones @LordFader
        last edited by PeterJones

        @LordFader said in URL to XML Structure:

        I can add <loc> etc

        How much does “etc” contain? Because knowing what you actually can achieve would have helped us explain what you were doing wrong.

        but I can’t get it to work in that form,

        you didn’t give us a form; you hinted at some attempts.

        I’ve tried a few things.

        And yet you don’t tell us what you tried, or explain what about their output didn’t match your expectation. You seem to have a high opinion of our Magic 8 Balls.

        Can anyone do it?

        With the level of detail you’ve given: not very likely. Until you provide actual information, rather than vague assertions, I’ll do my one attempt at mind reading. If this isn’t sufficient, you’ll have to try a bit harder to ask your question, because I won’t try to read your mind again.

        • FIND = (?-s)^(.*)$
          • grabs an entire line of text
        • REPLACE = <url>\r\n<loc>$1</loc>\r\n<lastmod>2023-09-12T15:00:00+00:00</lastmod>\r\n<changefreq>weekly</changefreq>\r\n</url>
          • most of that is literal text
          • the \r\n are the way to put a windows newline sequence in the output
          • the $1 takes the contents of the first parentheses group from the FIND (ie, your original line of text) and puts that same text in the replacement
        • SEARCH MODE = regular expression

        -—

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 4
        • L Offline
          LordFader
          last edited by

          Thanks PeterJones, it worked flawlessly.

          Now I also understand the principle, so I can easily adapt it. You just have to have seen once :-)

          Thanks!

          1 Reply Last reply Reply Quote 1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors