Long namespaces in building xml document, separated by the dots.

8 views
Skip to first unread message

Ruslan Strazhnyk

unread,
Sep 29, 2015, 7:06:17 AM9/29/15
to nokogiri-talk
Hello, 
I want to build an XML document, with such piece of code.
 <propertiesJMeter>
        <jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
  </propertiesJMeter>
 
but when I write it like this 

propertiesJMeter {
jmeter.save.saveservice.thread_counts 'true'
} 

I recieve such XML output, which is incorrect

<propertiesJMeter>
<jmeter class="save saveservice thread_counts">true</jmeter>
</propertiesJMeter> 

How should I use Nokogiri to avoid this?

Regards and thanks 

Mike Dalessio

unread,
Sep 29, 2015, 7:16:07 AM9/29/15
to nokogiri-talk

Hi Ruslan,

Thanks for asking this question.


On Sep 29, 2015 7:06 AM, "Ruslan Strazhnyk" <stra...@gmail.com> wrote:
>
> Hello, 
> I want to build an XML document, with such piece of code.
>>
>>  <propertiesJMeter>
>>         <jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
>>   </propertiesJMeter>
>
>  
> but when I write it like this 
>
>> propertiesJMeter {
>> jmeter.save.saveservice.thread_counts 'true'
>> } 
>

Can you show the Ruby code you're using?

>
> I recieve such XML output, which is incorrect
>
>> <propertiesJMeter>
>> <jmeter class="save saveservice thread_counts">true</jmeter>
>> </propertiesJMeter> 
>
>
> How should I use Nokogiri to avoid this?
>
> Regards and thanks 
>

> --
> You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
> To post to this group, send email to nokogi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nokogiri-talk.
> For more options, visit https://groups.google.com/d/optout.

Ruslan Strazhnyk

unread,
Sep 29, 2015, 7:20:42 AM9/29/15
to nokogiri-talk
Hello Mike,
yes, the code is the following http://pastebin.com/seA4V1pR

вівторок, 29 вересня 2015 р. 14:16:07 UTC+3 користувач Mike Dalessio написав:

Mike Dalessio

unread,
Sep 29, 2015, 8:50:56 AM9/29/15
to nokogiri-talk
Hi,

On Tue, Sep 29, 2015 at 7:20 AM, Ruslan Strazhnyk <stra...@gmail.com> wrote:
Hello Mike,
yes, the code is the following http://pastebin.com/seA4V1pR

The issue is that

    jmeter.save

is interpreted by Nokogiri Builder as a "Tag Attribute Short Cut" (as you can read about at http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Builder).

To make a tag with a "." in the tagname, you'll need to make sure ruby doesn't interpret the "." as an instance method call. This works:

    propertiesJMeter {
      send "jmeter.save.saveservice.thread_counts", 'true'
    }

and emits

    <propertiesJMeter>
      <jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
    </propertiesJMeter>

Make sense?
Reply all
Reply to author
Forward
0 new messages