I would very much like some help to get a table from a website into an XML document. I don’t know how to approach this. but I have found some code from another PowerShell.org Q/A thread.
My end goal is this: One the headlines says “Uddannelsessted” = “Place of Education” roughly translated.
I want to be able to see how far there is between my home address or Workplace to one the place mentioned under “Uddannelsessted”.
Here is some of the html information:
I would very much like some help to get a table from a website into an XML document. I don’t know how to approach this. but I have found some code from another PowerShell.org Q/A thread.
My end goal is this: One the headlines says “Uddannelsessted” = “Place of Education” roughly translated.
I want to be able to see how far there is between my home address or Workplace to one the places mentioned under “Uddannelsessted”. There are about 400 different options, so it would be really great if I with your help could get this to work.
You can use Invoke-WebRequest a bit more easily. What you’ll get back is “sorta” XML, and depending on the website might in fact be XML (e.g., XHTML). You just need to parse through the document object model (DOM) to find your table. On client computers, Invoke-WebRequest returns a parsed object; check out its properties and see if any of that helps you get just the table you want.
I’ve no idea how to go about calculating distance between places, though.
My thought on the distance calculation, was if you in some way could use Google maps in some way? But if adresses or Google maps could be seen as an object wouldn’t that hepl? Without knowing how to do it, I have learned that if powershell can be forced to see something as an object, then you can get somewhere.
The property 'Name' cannot be found on this object. Verify that the property exists and can be set.
At line:2 char:1
+ $r.Forms[0].Name = "title1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: [:] [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
The property 'Name' cannot be found on this object. Verify that the property exists and can be set.
At line:3 char:1
+ $r.Forms[0].Name = "title2"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: [:] [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Invoke-RestMethod : A content-body with this verb-type can not be sent.
(Sorry if this line doesn't make sence, I had to translate that from Danish to English.)
I don’t think you actually want to move the contents of the website to a CSV file, your goal is to extract the ‘Uddannelsessted’ out of that page right?
Looking at the HTML code, all the table rows containing the entries you’re interested in look like this: