• Login
Community
  • Login

URL to XML Structure

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 716 Views
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
    LordFader
    last edited by Sep 12, 2023, 1:34 PM

    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?

    P 1 Reply Last reply Sep 12, 2023, 2:11 PM Reply Quote 0
    • P
      PeterJones @LordFader
      last edited by PeterJones Sep 12, 2023, 2:13 PM Sep 12, 2023, 2:11 PM

      @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
        LordFader
        last edited by Sep 12, 2023, 2:48 PM

        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
        3 out of 3
        • First post
          3/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors