<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Namespaces in XML</title>
	<atom:link href="http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/</link>
	<description>The act of making love, tenderly.</description>
	<lastBuildDate>Wed, 01 Feb 2012 18:16:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Liz Trojan</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-127430</link>
		<dc:creator>Liz Trojan</dc:creator>
		<pubDate>Wed, 15 Dec 2010 00:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-127430</guid>
		<description>I have a namespace issue that I don&#039;t know how to resolve. I know you were thinking(hoping?) that this thread would die a quiet death but no such luck. I&#039;m attempting to merge an XML fragment into a larger XML doc. Below is my source.
 
require &#039;rubygems

# Here is how I generate the fragment
VEfragDoc = Nokogiri::XML::Builder.new do &#124;xml&#124;
  xml.root(&#039;xmlns&#039; =&gt; &#039;http://www.scte.org/schemas/130-3/2008a/adm&#039;,
    &#039;xmlns:core&#039; =&gt; &#039;http://www.scte.org/schemas/130-2/2008a/core&#039;,
    &#039;xmlns:xsi&#039; =&gt; &#039;http://www.w3.org/XMLSchema-instance&#039;,
    &#039;xsi:schemaLocation&#039; =&gt; &#039;http://www.scte.org/schemas/130-3/2008/adm SCTE130-3_2008.xsd&#039;,
    &#039;messageId&#039; =&gt; @messageId,
    &#039;version&#039; =&gt; &#039;1.0&#039;,
    &#039;identity&#039; =&gt; &#039;adm&#039;,
    &#039;system&#039; =&gt; &#039;adm&#039;){
    xml.ViewerEvent(:type =&gt; &quot;fast-forward&quot;, :time =&gt; &quot;2010-06-29T19:59:50.337+00:00&quot;){
      xml.Spot {
        xml[&#039;core&#039;].Content {
          xml[&#039;core&#039;].AssetRef(:assetID =&gt; &quot;CCDN2008010100090008&quot;, :providerID =&gt; &quot;adcontent.test.com&quot;)
          xml[&#039;core&#039;].Tracking &quot;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&quot;
        }
        xml.SpotNPT &quot;22.865&quot;, :scale =&gt; &quot;10.0&quot;
      }
    }
  }
  end.doc
  VEfragment = VEfragDoc.root.children

# Then I create the main document:
PSEdoc = Nokogiri::XML::Builder.new do &#124;xml&#124;
    xml.root(&#039;xmlns&#039; =&gt; &#039;http://www.scte.org/schemas/130-3/2008a/adm&#039;,
    &#039;xmlns:core&#039; =&gt; &#039;http://www.scte.org/schemas/130-2/2008a/core&#039;,
    &#039;xmlns:xsi&#039; =&gt; &#039;http://www.w3.org/XMLSchema-instance&#039;,
    &#039;xsi:schemaLocation&#039; =&gt; &#039;http://www.scte.org/schemas/130-3/2008/adm SCTE130-3_2008.xsd&#039;,
    &#039;messageId&#039; =&gt; @messageId,
    &#039;version&#039; =&gt; &#039;1.0&#039;,
    &#039;identity&#039; =&gt; &#039;adm&#039;,
    &#039;system&#039; =&gt; &#039;adm&#039;){
      xml.PlacementStatusEvent(:type =&gt; &quot;startPlacement&quot;, :time =&gt; &quot;2010-06-29T19:59:50.337+00:00&quot;){
        xml.Spot {
          xml[&#039;core&#039;].Content {
            xml[&#039;core&#039;].AssetRef(:assetID =&gt; &quot;XPTL2008010100090104&quot;, :providerID =&gt; &quot;adcontent.test.com&quot;)
            xml[&#039;core&#039;].Tracking &quot;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&quot;
          }
          xml.SpotNPT &quot;0.0&quot;, :scale =&gt; &quot;1.0&quot;
        }
      }
      xml.PlacementStatusEvent(:type =&gt; &quot;endPlacement&quot;, :time =&gt; &quot;2010-06-29T20:59:50.340+00:00&quot;){
        xml.Spot {
          xml[&#039;core&#039;].Content {
            xml[&#039;core&#039;].AssetRef(:assetID =&gt; &quot;XPTL2008010100090104&quot;, :providerID =&gt; &quot;adcontent.test.com&quot;)
            xml[&#039;core&#039;].Tracking &quot;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&quot;
          }
          xml.SpotNPT &quot;15.694&quot;, :scale =&gt; &quot;0.0&quot;
        }
      }    
    }
    end.doc

# Insert the fragment into the main doc
PSEdoc.xpath(&quot;//xmlns:PlacementStatusEvent[@type = &#039;startPlacement&#039;]&quot;).after VEfragment 
puts PSEdoc.to_xml


  
    
      
      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
    
    0.0
  

  
    
      
      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
    
    22.865
  

  
    
      
      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
    
    15.694
  



I had hoped for a merged file that looked like the following. Unfortunately some namespace stuff has been tacked on to the . 


 
    
      
        
        07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
      
      0.0
    
  
  
  
    
      
      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
    
    22.865
  

  
    
      
        
        07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19
      
      15.694
    
  

Any help with figuring out how to deal with namespaces when merging xml files would be greatly appreciated.
Liz</description>
		<content:encoded><![CDATA[<p>I have a namespace issue that I don&#8217;t know how to resolve. I know you were thinking(hoping?) that this thread would die a quiet death but no such luck. I&#8217;m attempting to merge an XML fragment into a larger XML doc. Below is my source.</p>
<p>require &#8216;rubygems</p>
<p># Here is how I generate the fragment<br />
VEfragDoc = Nokogiri::XML::Builder.new do |xml|<br />
  xml.root(&#8216;xmlns&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-3/2008a/adm&#039;" rel="nofollow">http://www.scte.org/schemas/130-3/2008a/adm&#039;</a>,<br />
    &#8216;xmlns:core&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-2/2008a/core&#039;" rel="nofollow">http://www.scte.org/schemas/130-2/2008a/core&#039;</a>,<br />
    &#8216;xmlns:xsi&#8217; =&gt; &#8216;<a href="http://www.w3.org/XMLSchema-instance&#039;" rel="nofollow">http://www.w3.org/XMLSchema-instance&#039;</a>,<br />
    &#8216;xsi:schemaLocation&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-3/2008/adm" rel="nofollow">http://www.scte.org/schemas/130-3/2008/adm</a> SCTE130-3_2008.xsd&#8217;,<br />
    &#8216;messageId&#8217; =&gt; @messageId,<br />
    &#8216;version&#8217; =&gt; &#8217;1.0&#8242;,<br />
    &#8216;identity&#8217; =&gt; &#8216;adm&#8217;,<br />
    &#8216;system&#8217; =&gt; &#8216;adm&#8217;){<br />
    xml.ViewerEvent(:type =&gt; &#8220;fast-forward&#8221;, :time =&gt; &#8220;2010-06-29T19:59:50.337+00:00&#8243;){<br />
      xml.Spot {<br />
        xml['core'].Content {<br />
          xml['core'].AssetRef(:assetID =&gt; &#8220;CCDN2008010100090008&#8243;, :providerID =&gt; &#8220;adcontent.test.com&#8221;)<br />
          xml['core'].Tracking &#8220;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&#8243;<br />
        }<br />
        xml.SpotNPT &#8220;22.865&#8243;, :scale =&gt; &#8220;10.0&#8243;<br />
      }<br />
    }<br />
  }<br />
  end.doc<br />
  VEfragment = VEfragDoc.root.children</p>
<p># Then I create the main document:<br />
PSEdoc = Nokogiri::XML::Builder.new do |xml|<br />
    xml.root(&#8216;xmlns&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-3/2008a/adm&#039;" rel="nofollow">http://www.scte.org/schemas/130-3/2008a/adm&#039;</a>,<br />
    &#8216;xmlns:core&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-2/2008a/core&#039;" rel="nofollow">http://www.scte.org/schemas/130-2/2008a/core&#039;</a>,<br />
    &#8216;xmlns:xsi&#8217; =&gt; &#8216;<a href="http://www.w3.org/XMLSchema-instance&#039;" rel="nofollow">http://www.w3.org/XMLSchema-instance&#039;</a>,<br />
    &#8216;xsi:schemaLocation&#8217; =&gt; &#8216;<a href="http://www.scte.org/schemas/130-3/2008/adm" rel="nofollow">http://www.scte.org/schemas/130-3/2008/adm</a> SCTE130-3_2008.xsd&#8217;,<br />
    &#8216;messageId&#8217; =&gt; @messageId,<br />
    &#8216;version&#8217; =&gt; &#8217;1.0&#8242;,<br />
    &#8216;identity&#8217; =&gt; &#8216;adm&#8217;,<br />
    &#8216;system&#8217; =&gt; &#8216;adm&#8217;){<br />
      xml.PlacementStatusEvent(:type =&gt; &#8220;startPlacement&#8221;, :time =&gt; &#8220;2010-06-29T19:59:50.337+00:00&#8243;){<br />
        xml.Spot {<br />
          xml['core'].Content {<br />
            xml['core'].AssetRef(:assetID =&gt; &#8220;XPTL2008010100090104&#8243;, :providerID =&gt; &#8220;adcontent.test.com&#8221;)<br />
            xml['core'].Tracking &#8220;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&#8243;<br />
          }<br />
          xml.SpotNPT &#8220;0.0&#8243;, :scale =&gt; &#8220;1.0&#8243;<br />
        }<br />
      }<br />
      xml.PlacementStatusEvent(:type =&gt; &#8220;endPlacement&#8221;, :time =&gt; &#8220;2010-06-29T20:59:50.340+00:00&#8243;){<br />
        xml.Spot {<br />
          xml['core'].Content {<br />
            xml['core'].AssetRef(:assetID =&gt; &#8220;XPTL2008010100090104&#8243;, :providerID =&gt; &#8220;adcontent.test.com&#8221;)<br />
            xml['core'].Tracking &#8220;07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19&#8243;<br />
          }<br />
          xml.SpotNPT &#8220;15.694&#8243;, :scale =&gt; &#8220;0.0&#8243;<br />
        }<br />
      }<br />
    }<br />
    end.doc</p>
<p># Insert the fragment into the main doc<br />
PSEdoc.xpath(&#8220;//xmlns:PlacementStatusEvent[@type = 'startPlacement']&#8220;).after VEfragment<br />
puts PSEdoc.to_xml</p>
<p>      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>    0.0</p>
<p>      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>    22.865</p>
<p>      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>    15.694</p>
<p>I had hoped for a merged file that looked like the following. Unfortunately some namespace stuff has been tacked on to the . </p>
<p>        07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>      0.0</p>
<p>      07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>    22.865</p>
<p>        07ecc860-d4a3-012d-0c3f-005056c00008_1_3_19</p>
<p>      15.694</p>
<p>Any help with figuring out how to deal with namespaces when merging xml files would be greatly appreciated.<br />
Liz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mario</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-116604</link>
		<dc:creator>mario</dc:creator>
		<pubDate>Mon, 14 Jun 2010 18:23:48 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-116604</guid>
		<description>Aaron,

This article was REALLY helpful for me.  Nokogiri is a godsend and i just wanted to thank you for writing in a way that makes it fun/easy to understand while still driving home the key points.</description>
		<content:encoded><![CDATA[<p>Aaron,</p>
<p>This article was REALLY helpful for me.  Nokogiri is a godsend and i just wanted to thank you for writing in a way that makes it fun/easy to understand while still driving home the key points.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan Reeves</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-110639</link>
		<dc:creator>Evan Reeves</dc:creator>
		<pubDate>Wed, 24 Feb 2010 18:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-110639</guid>
		<description>I feel like an idiot for not having discovered this explanation earlier (here or anywhere else!). Thanks for this explanation and special thanks for giving Nokogiri examples. My Ruby n00b ass has a much better understanding now!</description>
		<content:encoded><![CDATA[<p>I feel like an idiot for not having discovered this explanation earlier (here or anywhere else!). Thanks for this explanation and special thanks for giving Nokogiri examples. My Ruby n00b ass has a much better understanding now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Patterson</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-103647</link>
		<dc:creator>Aaron Patterson</dc:creator>
		<pubDate>Tue, 17 Nov 2009 18:45:02 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-103647</guid>
		<description>@john yes, good catch.  I will fix.  Thanks!</description>
		<content:encoded><![CDATA[<p>@john yes, good catch.  I will fix.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-103646</link>
		<dc:creator>john</dc:creator>
		<pubDate>Tue, 17 Nov 2009 18:37:13 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-103646</guid>
		<description>Um, should this be doc.xpath, etc.?

doc.xml(&#039;//tire&#039;)
doc.xml(&#039;//aliceAuto:tire&#039;,
  &#039;aliceAuto&#039; =&gt; &#039;http://alicesautosupply.example.com/&#039;
)</description>
		<content:encoded><![CDATA[<p>Um, should this be doc.xpath, etc.?</p>
<p>doc.xml(&#8216;//tire&#8217;)<br />
doc.xml(&#8216;//aliceAuto:tire&#8217;,<br />
  &#8216;aliceAuto&#8217; =&gt; &#8216;<a href="http://alicesautosupply.example.com/" rel="nofollow">http://alicesautosupply.example.com/</a>&#8216;<br />
)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Smick</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-77052</link>
		<dc:creator>Jeff Smick</dc:creator>
		<pubDate>Sun, 17 May 2009 19:16:44 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-77052</guid>
		<description>&lt;p&gt;How would I find the inventory node for a specific namespace?&lt;/p&gt;

&lt;p&gt;If we put the two together:


  
  


  
  
&lt;/p&gt;

&lt;p&gt;What query would I use to find Bob&#039;s inventory?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>How would I find the inventory node for a specific namespace?</p>
<p>If we put the two together:</p>
<p>What query would I use to find Bob&#8217;s inventory?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-75941</link>
		<dc:creator>Bruce</dc:creator>
		<pubDate>Thu, 07 May 2009 01:38:53 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-75941</guid>
		<description>&lt;p&gt;Maybe a dumb question, but do you have to declare the bindings on every xpath method call, or can you register them independently (which can be useful, particularly if you&#039;re dealing with a lot of content with default namespaces)?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Maybe a dumb question, but do you have to declare the bindings on every xpath method call, or can you register them independently (which can be useful, particularly if you&#8217;re dealing with a lot of content with default namespaces)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Patterson</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-74520</link>
		<dc:creator>Aaron Patterson</dc:creator>
		<pubDate>Fri, 24 Apr 2009 01:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-74520</guid>
		<description>&lt;p&gt;@Dr Nic: You could, but then you would have to standardize on an attribute name.  Everyone would have to agree on one particular attribute name to examine.  If you gave me your XML document, you would have to tell me to examine the &quot;type&quot; attribute, where someone else might choose the &quot;class&quot; attribute.  The namespace attribute is standardized.&lt;/p&gt;

&lt;p&gt;Not to mention in your example, the attribute value would have to be unique.  I couldn&#039;t tell the difference between a car tire from Ford and a car tire from GM.  ;-)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Dr Nic: You could, but then you would have to standardize on an attribute name.  Everyone would have to agree on one particular attribute name to examine.  If you gave me your XML document, you would have to tell me to examine the &#8220;type&#8221; attribute, where someone else might choose the &#8220;class&#8221; attribute.  The namespace attribute is standardized.</p>
<p>Not to mention in your example, the attribute value would have to be unique.  I couldn&#8217;t tell the difference between a car tire from Ford and a car tire from GM.  <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr Nic</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-74503</link>
		<dc:creator>Dr Nic</dc:creator>
		<pubDate>Fri, 24 Apr 2009 00:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-74503</guid>
		<description>&lt;pre&gt;&lt;tire type=&#039;car&#039;&gt;...&lt;/tire&gt;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<pre>&lt;tire type='car'&gt;...&lt;/tire&gt;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr Nic</title>
		<link>http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/comment-page-1/#comment-74499</link>
		<dc:creator>Dr Nic</dc:creator>
		<pubDate>Thu, 23 Apr 2009 23:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=237#comment-74499</guid>
		<description>&lt;p&gt;So why namespacing vs element attributes?&lt;/p&gt;

&lt;p&gt;e.g. &lt;/p&gt;

&lt;pre&gt;...&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>So why namespacing vs element attributes?</p>
<p>e.g. </p>
<pre>...</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

