Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Catastro WebService Query in PowerShell] Query and process Xml Result for Catastro in PowerShell #xml #PowerShell #webservice
function Consulta_DPNRC($cod_parcela) {
$response = Invoke-WebRequest -UseBasicParsing -Uri "http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/Consulta_DNPRC" `
-Method "POST" `
-WebSession $session `
-Headers @{
"Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
"Accept-Encoding"="gzip, deflate"
"Accept-Language"="es-419,es;q=0.9,en;q=0.8"
"Cache-Control"="no-cache"
"Origin"="null"
"Pragma"="no-cache"
"Upgrade-Insecure-Requests"="1"
} `
-ContentType "application/x-www-form-urlencoded" `
-Body "Provincia=&Municipio=&RC=$cod_parcela";
$xml = [xml]($response.Content);
$ns = @{"c"="http://www.catastro.meh.es/"};
$res = @{
Addr=(($xml | Select-Xml -Namespace $ns -XPath "//c:ldt[1]").Node.InnerText);
Ant=(($xml | Select-Xml -Namespace $ns -XPath "//c:ant[1]").Node.InnerText);
Us=(($xml | Select-Xml -Namespace $ns -XPath "//c:luso[1]").Node.InnerText);
Sup=(($xml | Select-Xml -Namespace $ns -XPath "//c:sfc[1]").Node.InnerText)
}
$res
}
Consulta_DPNRC("6382908DF3868A0001HB")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment