# Watir: XML Element includes Escape Sequences

**URL:** <https://www.ruby-forum.com/t/watir-xml-element-includes-escape-sequences/126400>\
**Category:** Ruby\
**Created:** [January 17, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/watir-xml-element-includes-escape-sequences/126400 "2008-01-17T23:54:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liscoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ee7513/32.png) [@liscoo](https://www.ruby-forum.com/u/liscoo)\
**Post date:** [January 17, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/watir-xml-element-includes-escape-sequences/126400/1 "2008-01-17T23:54:23Z")

</div>

I’m working on a test script using Watir. I’m new to Ruby and I’m  
struggling with syntax.

if (ARGV[0] == nil)  
#caseName = ‘Default’  
caseName = ‘Other’  
else  
caseName = ARGV[0]  
end

root = doc.root  
testCasePath = “\*TestCases/TestCase[@name=’” + caseName + “’]”

REXML::XPath.each(doc.root, testCasePath) do |elt|  
if (elt.attributes[“name”] == caseName)  
FirstName =elt.elements[“FirstName”].text  
puts FirstName

When I get the FirstName value there are a bunch of escape characters  
(/n/t/t) coming from the XML document.

Do I have bad syntax or is there another problem?

Thanks.

---

<div class="post-metadata">

**Author:** ![liscoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ee7513/32.png) [@liscoo](https://www.ruby-forum.com/u/liscoo)\
**Post date:** [January 18, 2008, 12:00am UTC](https://www.ruby-forum.com/t/watir-xml-element-includes-escape-sequences/126400/2 "2008-01-18T00:00:01Z")

</div>

Never mind. As soon as I posted, I figured it out.

I was using the Visual Studio IDE to create my XML document. I didn’t  
realize that the IDE added formatting characters. I moved my XML to  
notepad and it worked fine.

Hopefully this post will help someone else.

Lisa Cook wrote:

> I’m working on a test script using Watir. I’m new to Ruby and I’m  
> struggling with syntax.
> 
> if (ARGV[0] == nil)  
> #caseName = ‘Default’  
> caseName = ‘Other’  
> else  
> caseName = ARGV[0]  
> end
> 
> root = doc.root  
> testCasePath = “\*TestCases/TestCase[@name=’” + caseName + “’]”
> 
> REXML::XPath.each(doc.root, testCasePath) do |elt|  
> if (elt.attributes[“name”] == caseName)  
> FirstName =elt.elements[“FirstName”].text  
> puts FirstName
> 
> When I get the FirstName value there are a bunch of escape characters  
> (/n/t/t) coming from the XML document.
> 
> Do I have bad syntax or is there another problem?
> 
> Thanks.
