I wrote a web service in C#/ASP and published in IIS. This web service performs a function for Windows servers during the build process. I need the client to make the web call and grab the auto-generated GUID that is returned from the service and write it to a text file. However I am having issues pulling out just what I need. Here is an example of the data returned from the call, which is done using rest-client in Ruby: <?xml version="1.0" encoding="utf-8"?> <string xmlns="companyname.confidential.automation">THIS IS THE DATA I NEED TO KEEP FROM THIS WEB CALL</string> How do I pull out JUST the bolded stuff above? Note there are no spaces in the GUID that is generated. I don't believe xmlsimple will do what I want. I'd rather avoid using something like str.sub(target, '') on this kind of call because of obvious reasons. I am open to any suggestions. Thanks!
on 2012-12-18 21:27
on 2012-12-18 21:42
Look at nokogiri. http://nokogiri.org It will parse the data you are looking for. Wayne
on 2012-12-18 22:32
Actually I was looking past the real issue, which was a problem with the data being returned. Needed to throw in a base64 encode and decode to get the right XML data so the parser didn't flip out. Thanks Wayne for jumping in fast. I will take a look at nokogiri because I think I will need it for the next step in my project.
on 2012-12-19 00:32
require 'nokogiri'
xml =<<MY_XML
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="companyname.confidential.automation">THIS IS THE DATA I
NEED TO KEEP FROM THIS WEB CALL</string>
MY_XML
doc = Nokogiri::XML(xml)
puts doc.root.text()
puts doc.xpath('//text()[1]')
--output:--
THIS IS THE DATA I NEED TO KEEP FROM THIS WEB CALL
THIS IS THE DATA I NEED TO KEEP FROM THIS WEB CALL
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.