Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORMAT output of Debug.Print .responseText (from api rest)

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
425
IT
<?xml version="1.0" encoding="utf-8"?><Response xmlns:xsd=" xmlns:xsi=" xmlns=" © 2024 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright><BrandLogoUri> Provinciale Quarantasette 27, 89818 Capistrano VV, Italia</Name><Point><Latitude>38.6857407</Latitude><Longitude>16.2937848</Longitude></Point><BoundingBox><
SouthLatitude>38.68187798242932</SouthLatitude><WestLongitude>16.287187176966889</WestLongitude><NorthLatitude>38.689603417570673</NorthLatitude><EastLongitude>16.300382423033113</EastLongitude></BoundingBox><EntityType>Address</EntityType><Address><AddressLine>Strada Provinciale Quarantasette 27</AddressLine><AdminDistrict>Cal.</AdminDistrict><AdminDistrict2>VV</AdminDistrict2><CountryRegion>Italia</CountryRegion><FormattedAddress>Strada Provinciale Quarantasette 27, 89818 Capistrano VV, Italia</FormattedAddress><Locality>Capistrano</Locality><PostalCode>89818</PostalCode><Intersection><BaseStreet>Strada Provinciale Quarantasette</BaseStreet><SecondaryStreet1>Via Dante Alighieri</SecondaryStreet1><IntersectionType>Near</IntersectionType><DisplayName>Strada Provinciale Quarantasette and Via Dante Alighieri</DisplayName></Intersection></Address><Confidence>High</Confidence><MatchCode>Good</MatchCode><GeocodePoint><Latitude>38.6857407</Latitude><Longitude>16.2937848</Longitude><CalculationMethod>Rooftop</Calcu
lationMethod><UsageType>Display</UsageType></GeocodePoint></Location></Resources></ResourceSet></ResourceSets></Response>

Is possible to format the output type in attached file? and save as txt in c:\mydir\prova.txt

?

Tks

 
Sure. Here's an example of one method. Note it is not production code and fails if you do not pass it 100% correct XML. And, I shouold point out, neither the text you psotred above, nor the linked file, are 100% correct XML ...

Code:
[COLOR=blue][COLOR=green]' Example. Only works with correctly formatted XML. Fails if it is not.
' Requires a reference to Microsoft XML, v6.0 library[/color]
Public Function PrettyPrintXML(XML As String) As String

    Dim xslDoc As New DOMDocument60
    Dim Reader As New SAXXMLReader60
    Dim Writer As New MXXMLWriter60
  
    xslDoc.LoadXML XML
  
    Writer.indent = True
    Writer.standalone = False
    Writer.omitXMLDeclaration = False
    Writer.Encoding = "utf-8"

    Set Reader.contentHandler = Writer
    Reader.Parse xslDoc

    PrettyPrintXML = Writer.output
End Function[/color]
 
Hi bro.
I can pass directlly .responseText in xml as string?
 
Should be able to, yes. Of course, you could have just tried it ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top