M
M
Mikhail Vasiliev2015-01-01 20:04:40
XML
Mikhail Vasiliev, 2015-01-01 20:04:40

How to get data from sitemap.xml?

There is an xml file where the data is located as follows:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://site.ru</loc>
</url>
</urlset>

You need to get site.ru and display it on the page. How to do it? :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Vsk, 2015-01-02
@viktorvsk

Taking into account the tags of the question, I will answer:
Select site.ru with the mouse and press ctrl + c.
And so, they can offer to either pull out a regular expression (in the end, there will be something like /^<loc>(.*?)<\/loc>/) Or, more correctly, use DOM parsers.
No language was specified, so here's PHP:
php.net/manual/ru/book.simplexml.php
Here's ruby:
www.nokogiri.org
Python:
https://docs.python.org/2/library/xml.etree. elements...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question