Home > Software engineering >  Get value from html tag value with colon using XPath
Get value from html tag value with colon using XPath

Time:03-27

enter image description here

I am trying to get value from this attribute

:news-item-data

type <div  id="app">
                <div >
                    <news-item :news-item-data="{&quot;id&quot;:248934,&quot;url&quot;:&quot;na-treh-ulicah-gorroshi-otklyuchili-holodnuyu-vodu-248934&quot;,&quot;title&quot;:&quot;\u041d\u0430\u00a0\u0442\u0440\u0435\u0445 \u0443\u043b\u0438\u0446\u0430\u0445 \u0413\u043e\u0440\u0440\u043e\u0449\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0445\u043e\u043b\u043e\u0434\u043d\u0443\u044e \u0432\u043e\u0434\u0443&quot;,&quot;date&quot;:&quot;2022-03-25T06:58:03.000000Z&quot;,&quot;notice&quot;:&quot;\u0412\u00a0\u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u043f\u0430\u043b\u0438 \u0436\u0438\u043b\u044b\u0435 \u0434\u043e\u043c\u0430, \u0442\u0435\u0445\u043d\u043e\u043f\u0430\u0440\u043a \u00ab\u041a\u0432\u0430\u043d\u0442\u043e\u0440\u0438\u0443\u043c \u00ab\u0414\u0440\u0443\u0436\u0431\u0430\u00bb, \u0434\u0435\u0442\u0441\u043a\u0430\u044f \u043f\u043e\u043b\u0438\u043a\u043b\u0438\u043d\u0438\u043a\u0430 \u2116\u20091 \u0438\u00a0\u043e\u043d\u043a\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0438\u0441\u043f\u0430\u043d\u0441\u0435\u0440.&quot;,&quot;body&quot;:&quot;&lt;p&gt;\u041d\u0430\u00a0\u0442\u0440\u0435\u0445 \u0443\u043b\u0438\u0446\u0430\u0445 \u0413\u043e\u0440\u0440\u043e\u0449\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0445\u043e\u043b\u043e\u0434\u043d\u0443\u044e \u0432\u043e\u0434\u0443. \u041e\u0431\u00a0\u044d\u0442\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0438\u043b\u0438 \u043d\u0430 &lt;noindex&gt;&lt;a rel=\&quot;nofollow\&quot; target=\&quot;_blank\&quot;href=\&quot;https:\/\/vodokanalryazan.ru\/press-tsentr\/remontnye-raboty\/:otklyuchenie-holodnoj-vody-25032022\&quot;&gt;\u0441\u0430\u0439\u0442\u0435&lt;\/a&gt;&lt;\/noindex&gt; \u0440\u044f\u0437\u0430\u043d\u0441\u043a\u043e\u0433\u043e \u0432\u043e\u0434\u043e\u043a\u0430\u043d\u0430\u043b\u0430. &lt;\/p&gt;\r\n&lt;p&gt;\u0412\u00a0\u043f\u044f\u0442\u043d\u0438\u0446\u0443, 25\u00a0\u043c\u0430\u0440\u0442\u0430, \u0441\u00a009:30 \u0434\u043e\u00a017:00 \u0445\u043e\u043b\u043e\u0434\u043d\u0443\u044e \u0432\u043e\u0434\u0443 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043f\u043e\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c: &lt;\/p&gt;\n&lt;ul&gt;\n&lt;li&gt;\u0443\u043b\u0438\u0446\u0430 \u0412\u044b\u0441\u043e\u043a\u043e\u0432\u043e\u043b\u044c\u0442\u043d\u0430\u044f, \u0434\u043e\u043c \u2116\u20095 \u043a\u043e\u0440\u043f\u0443\u0441 1; &lt;\/li&gt;\n&lt;li&gt;\u0422\u0440\u043e\u043b\u043b\u0435\u0439\u0431\u0443\u0441\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0443\u043b\u043e\u043a, \u0434\u043e\u043c\u0430 \u2116\u2116\u20094, 6;&lt;\/li&gt;\n&lt;li&gt;\u0443\u043b\u0438\u0446\u0430 \u0414\u0437\u0435\u0440\u0436\u0438\u043d\u0441\u043a\u043e\u0433\u043e, \u0434\u043e\u043c\u0430 \u0441\u00a04 \u043f\u043e\u00a018 (\u0447\u0435\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430), \u0441\u00a07 \u043f\u043e\u00a013 (\u043d\u0435\u0447\u0435\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430), 6 (\u0434\u0435\u0442\u0441\u043a\u0438\u0439 \u0442\u0435\u0445\u043d\u043e\u043f\u0430\u0440\u043a \u00ab\u041a\u0432\u0430\u043d\u0442\u043e\u0440\u0438\u0443\u043c \u00ab\u0414\u0440\u0443\u0436\u0431\u0430\u00bb), 8 \u0438\u00a016-\u0430 (\u0434\u0435\u0442\u0441\u043a\u0430\u044f \u043f\u043e\u043b\u0438\u043a\u043b\u0438\u043d\u0438\u043a\u0430 \u2116\u20091), 11 (\u043e\u0431\u043b\u0430\u0441\u0442\u043d\u043e\u0439 \u043a\u043b\u0438\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043d\u043a\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0438\u0441\u043f\u0430\u043d\u0441\u0435\u0440).&lt;\/li&gt;\n&lt;\/ul&gt;\n&lt;p&gt;\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u00a0\u2014 \u0440\u0435\u043c\u043e\u043d\u0442\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u00a0\u0432\u043e\u0434\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u0435. &lt;\/p&gt;&quot;,&quot;date_insert&quot;:&quot;2022-03-25T06:59:48.000000Z&quot;,&quot;active&quot;:true,&quot;image&quot;:null,&quot;old&quot;:false,&quot;is_comment&quot;:true,&quot;is_priority&quot;:false,&quot;metadata&quot;:false,&quot;is_mail&quot;:true,&quot;comments_count&quot;:0,&quot;read_count&quot;:92,&quot;image_1&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa.jpg&quot;,&quot;section_meta&quot;:null,&quot;gallery&quot;:false,&quot;photographer_id&quot;:null,&quot;is_ad&quot;:false,&quot;is_priority_small&quot;:false,&quot;editor_id&quot;:19591,&quot;indexation_inner_link&quot;:false,&quot;injection&quot;:null,&quot;material_id&quot;:null,&quot;photobank_id&quot;:null,&quot;annotation&quot;:null,&quot;is_telegram&quot;:false,&quot;is_bisy&quot;:false,&quot;image_2&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa_x2.jpg&quot;,&quot;rate_plus&quot;:0,&quot;rate_minus&quot;:0,&quot;fb_post_id&quot;:null,&quot;fb_status&quot;:null,&quot;fb_instant_article&quot;:null,&quot;google_shortlink&quot;:null,&quot;news_rss&quot;:null,&quot;is_telegram_mainchannel&quot;:false,&quot;totalSocialCount&quot;:0,&quot;is_yandexturbo&quot;:false,&quot;is18&quot;:false,&quot;source_type&quot;:null,&quot;region_groups&quot;:false,&quot;fb_post_url&quot;:null,&quot;social_is_sent&quot;:true,&quot;tg_post_id&quot;:&quot;113523&quot;,&quot;ok_post_id&quot;:&quot;153952320566716&quot;,&quot;tg_post_url&quot;:&quot;https:\/\/t.me\/rzninfo_news_channel\/113523&quot;,&quot;ok_post_url&quot;:&quot;https:\/\/ok.ru\/group\/51938318221500\/topic\/153952320566716&quot;,&quot;image_1_compressed&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa_compressed.jpg&quot;,&quot;image_1_x2&quot;:null,&quot;image_1_compressed_x2&quot;:null,&quot;image_social_compressed_x2&quot;:null,&quot;is_new_admin&quot;:true,&quot;placeholder&quot;:false,&quot;image_600_400&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa_600_400.jpg&quot;,&quot;image_300_200&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa_300_200.jpg&quot;,&quot;image_2_compressed&quot;:&quot;2022\/03\/248934\/248934_623d6864d19fa_x2_compressed.jpg&quot;,&quot;created_at&quot;:&quot;2022-03-25T06:59:48.000000Z&quot;,&quot;updated_at&quot;:&quot;2022-03-25T06:59:49.000000Z&quot;,&quot;is_delayed&quot;:false,&quot;commentsTree&quot;:[],&quot;isShowComments&quot;:false,&quot;inBookmarks&quot;:false,&quot;socialImagesOpengraph&quot;:&quot;https:\/\/cdn9.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_openGraph.jpg&quot;,&quot;socialImagesVk&quot;:&quot;https:\/\/cdn7.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_vk.jpg&quot;,&quot;socialImagesTwitter&quot;:&quot;https:\/\/cdn9.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_twitter.jpg&quot;,&quot;socialImagesFacebook&quot;:&quot;https:\/\/cdn8.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_fb.jpg&quot;,&quot;socialImagesOk&quot;:&quot;https:\/\/cdn7.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_ok.jpg&quot;,&quot;socialImagesTg&quot;:&quot;https:\/\/cdn10.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/socials\/248934_623d6864d19fa_social_telegram.jpg&quot;,&quot;comments_count_label&quot;:&quot;\u041f\u0440\u043e\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&quot;,&quot;date_formatted&quot;:&quot;23 \u043c\u0438\u043d\u0443\u0442\u044b \u043d\u0430\u0437\u0430\u0434&quot;,&quot;read_count_formatted&quot;:&quot;92&quot;,&quot;comment_count_formatted&quot;:&quot;0&quot;,&quot;public_url&quot;:&quot;https:\/\/www.rzn.info\/news\/2022\/3\/25\/na-treh-ulicah-gorroshi-otklyuchili-holodnuyu-vodu-248934.html&quot;,&quot;desktop_url&quot;:&quot;https:\/\/www.rzn.info\/news\/2022\/3\/25\/na-treh-ulicah-gorroshi-otklyuchili-holodnuyu-vodu-248934.html&quot;,&quot;mobile_url&quot;:&quot;https:\/\/m.rzn.info\/news\/2022\/3\/25\/na-treh-ulicah-gorroshi-otklyuchili-holodnuyu-vodu-248934.html&quot;,&quot;image_1_public_url&quot;:&quot;https:\/\/cdn7.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/248934_623d6864d19fa_compressed.jpg&quot;,&quot;image_2_public_url&quot;:&quot;https:\/\/cdn6.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/248934_623d6864d19fa_x2_compressed.jpg&quot;,&quot;image_600_400_public_url&quot;:&quot;https:\/\/cdn6.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/248934_623d6864d19fa_600_400.jpg&quot;,&quot;image_300_200_public_url&quot;:&quot;https:\/\/cdn6.rzn.info\/data\/image\/newsadd\/base\/2022\/03\/248934\/248934_623d6864d19fa_300_200.jpg&quot;,&quot;stories&quot;:[],&quot;sections&quot;:[{&quot;id&quot;:1,&quot;title&quot;:&quot;\u0420\u044f\u0437\u0430\u043d\u044c&quot;,&quot;url&quot;:&quot;ryazan&quot;,&quot;parent&quot;:0,&quot;order&quot;:100,&quot;on_main&quot;:true,&quot;public_url&quot;:&quot;https:\/\/www.rzn.info\/news\/ryazan&quot;,&quot;desktop_url&quot;:&quot;https:\/\/www.rzn.info\/news\/ryazan&quot;,&quot;mobile_url&quot;:&quot;https:\/\/m.rzn.info\/news\/ryazan&quot;,&quot;pivot&quot;:{&quot;data_id&quot;:248934,&quot;section_id&quot;:1}},{&quot;id&quot;:14,&quot;title&quot;:&quot;\u0416\u041a\u0425 \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442&quot;,&quot;url&quot;:&quot;services-and-transport&quot;,&quot;parent&quot;:0,&quot;order&quot;:96,&quot;on_main&quot;:false,&quot;public_url&quot;:&quot;https:\/\/www.rzn.info\/news\/services-and-transport&quot;,&quot;desktop_url&quot;:&quot;https:\/\/www.rzn.info\/news\/services-and-transport&quot;,&quot;mobile_url&quot;:&quot;https:\/\/m.rzn.info\/news\/services-and-transport&quot;,&quot;pivot&quot;:{&quot;data_id&quot;:248934,&quot;section_id&quot;:14}}],&quot;comments&quot;:[],&quot;galleries&quot;:null,&quot;areas&quot;:[],&quot;photobank&quot;:null,&quot;authors&quot;:[],&quot;resource&quot;:{&quot;id&quot;:249983,&quot;date&quot;:&quot;2022-03-25T06:59:48.000000Z&quot;,&quot;new_id&quot;:248934,&quot;article_id&quot;:null,&quot;business_id&quot;:null,&quot;seriously_id&quot;:null,&quot;active&quot;:true,&quot;tags&quot;:[]},&quot;social_images&quot;:{&quot;id&quot;:11767,&quot;type_and_realization&quot;:&quot;news&quot;,&quot;data_id&quot;:248934,&quot;active_theme&quot;:&quot;horizontal&quot;,&quot;opengraph&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_openGraph.jpg&quot;,&quot;vk&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_vk.jpg&quot;,&quot;fb&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_fb.jpg&quot;,&quot;twitter&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_twitter.jpg&quot;,&quot;ok&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_ok.jpg&quot;,&quot;tg&quot;:&quot;2022\/03\/248934\/socials\/248934_623d6864d19fa_social_telegram.jpg&quot;,&quot;created_at&quot;:&quot;2022-03-25T06:59:49.000000Z&quot;,&quot;updated_at&quot;:&quot;2022-03-25T06:59:49.000000Z&quot;},&quot;bookmark&quot;:null}"
                          :icon-comment="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-comment&quot;"
                          :icon-eye="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-eye&quot;"
                          :icon-bookmark="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-bookmark&quot;"
                          :icon-facebook="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-facebook&quot;"
                          :icon-vk="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-vkontakte&quot;"
                          :icon-telegram="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-telegram&quot;"
                          :icon-twitter="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-twitter&quot;"
                          :icon-odboklassniki="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/sprite.svg#icon-odnoklassniki&quot;"
                          :add-comment-url="&quot;https:\/\/www.rzn.info\/ajax\/newsitem\/addComment\/&quot;"
                          :add-like-url="&quot;https:\/\/www.rzn.info\/ajax\/newsitem\/addlike\/&quot;"
                          :next-item-url="&quot;https:\/\/www.rzn.info\/ajax\/newsitem\/next\/&quot;"
                          :user-id="null"
                          :token="&quot;H9cvR75xBtprSNSxTFtW8RB7YkROKMIsZQHYsMoY&quot;"
                          :current-rubric="&quot;services-and-transport&quot;"
                          :spinner="&quot;https:\/\/www.rzn.info\/assets\/images\/design\/spinner.svg&quot;"
                          :city="&quot;ryazan&quot;"
                          :city-trans="&quot;\u0420\u044f\u0437\u0430\u043d\u044c&quot;"
                          :add-to-bookmarks-url="&quot;https:\/\/www.rzn.info\/ajax\/newsitem\/addToBookmarks\/&quot;"
                          :remove-from-bookmarks-url="&quot;https:\/\/www.rzn.info\/ajax\/newsitem\/removeFromBookmarks\/&quot;">
                    </news-item>
                </div>
                <div >here

But i dont know how to get :attribute value.

Usually i use something like //div[contains(@class, 'col9')]/news-item/@news-item-data but here a i have : before news-item-data, so how do i get value inside :news-item-data using xpath?

I tried //div[contains(@class, 'col9')]/news-item/@news-item-data expected to get value inside of :news-item-data

CodePudding user response:

To select the :news-item-data attribute value in XML you presenting here you can use this XPath:

//div[contains(@class, 'col-8')]/news-item/@*[name()=':news-item-data']

UPD
I could not find the XML block on the link you provided in the comment. Possibly the web site is dynamic.
You can see my XPath applied to XML you provided in the question here: enter image description here:

Generally it's a nice online XPath simulator

  • Related