We help IT Professionals succeed at work.

convert the xml POST response to a text file without the tagnames?

GeneBe
GeneBe asked
this is a VBscript  How do I convert the xml response to a text file without the tagnames?

Dim xml : xml = PostURL(HRP_BaseDomain & path, values)

Dim oXMLDoc, oXMLHTTP, oXMLResults, oXMLFields
Function PostURL(path, values)
   LogItem "path: " & HRP_BaseDomain & "   " &  path : LogError : Err.Clear
   On Error Resume Next
   set oXMLHTTP = createobject ("MSXML2.XMLHTTP.6.0")
   oXMLHTTP.open "POST", path, false
   oXMLHTTP.setRequestHeader "Content-type","application/x-www-form-urlencoded"
  oXMLHTTP.send values
   LogError : Err.Clear
   PostURL = oXMLHTTP.responseText
End Function

Open in new window

Comment
Watch Question

ZvonkoSystems architect
BRONZE EXPERT
Top Expert 2006
Show the response from this property:  oXMLHTTP.responseXML.xml

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms757055(v%3Dvs.85) 

Author

Commented:
this gives me an xml response. I need a text formatted response without the tags
Systems architect
BRONZE EXPERT
Top Expert 2006
Extend your Function like this:
...
   Dim oRegExp
   Set oRegExp = New RegExp
   oRegExp.Pattern = "\<[^\>]+\>"
   oRegExp.Global = True
   PostURL = oRegExp.Replace(oXMLHTTP.responseText, "")
   'remove: PostURL = oXMLHTTP.responseText
End Function
Bill PrewTest your restores, not your backups...
SILVER EXPERT
Expert of the Year 2019
Top Expert 2016
A sample of the output XML would be helpful, an answer may be driven by the structure and content of the XML, since XML can look a lot different between a simple schema and a very complex one.  With the XML sample a sample of the desired text output would be helpful.

You may be able to do something with an XSLT transformation, although I'm not very well skilled on that.  Take a look at this earlier question for an idea of that approach, but notice that to make it most useful it needs to know what the specific data looked liked, etc.



»bp

Author

Commented:
Please close this issue. your solution worked. thank you very much.