Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Grab Values within HTML Tag

$
0
0

<div class="primary-title-and-description"><h1>
		Title Here</h1><p>
		Paragraph Here</p></div><div class="secondary-title-and-description"><h1>
		Secondary Title Here</h1><p>
		Secondary Paragraph Here</p></div>

Hi

I am trying to get the values within the <h1></h1> only from the <div class="primary-title-and-description">. How do I go about doing that?

I tried my luck with the below code but no joy. What I did was copy the above code and save it as test.html and I use the code below.

$test = gc test.html |%{[regex]::matches( $_ ,'(?<=<div class="primary-title-and-description">\s+)(.*?)(?=\s+</h1>)')}|select-expa value
$test

I did not get any response from the powershell. What have I done wrong? Should I use xml method to get the values?


Thanks


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>