URL to XML Structure
-
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?
-
@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\nare the way to put a windows newline sequence in the output - the
$1takes 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
- FIND =
-
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!
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