Hello Ben. The xmls attr on your root node defines a default namespace.

I blogged about it here: 
http://aaronjwhite.org/index.php/component/content/article/2-cfml/10-coldfusion-xmlsearch-and-epub-open-container-format
 

So you have two options. All you have to do is add a colon (: ) in front of 
your nodes like so: "/:StudentPersonal/:Name"
OR
You can use very sexy new html() function for jQuery like searches 
(OpenCfSummit ftw). Reference: http://www.openbd.org/manual/?/function/html
 Download the nightly and then try the code below:

//** CODE **//

<html><body><h1>XML Searching</h1>

<cfset xmlStr = '<StudentPersonal 
xmlns="http://www.sifinfo.org/infrastructure/2.x"; 
RefId="140808190A00040F5007AA16589D65EB"> 
<LocalId>20602</LocalId> 
<Name Type="04"> 
<LastName>Serrano</LastName> 
<FirstName>Nadine</FirstName> 
<MiddleName>H</MiddleName> 
<FullName>Serrano, Nadine H</FullName> 
</Name> 
</StudentPersonal>'
/> 
<cfset  xmlObj = xmlParse(xmlStr) />
<cfset xmlResult = xmlSearch(xmlobj, "/:StudentPersonal") />
<cfset xmlNameType= xmlSearch(xmlobj, "/:StudentPersonal/:Name/@Type") />
<cfset htmlObj= html(xmlStr) />
<cfset htmlResult= htmlobj.select('StudentPersonal') />
<cfset htmlNameType= htmlobj.select('StudentPersonal Name').attr('Type') />

<h3>Html Result:</h3><cfdump var="#htmlResult.outerhtml()#" expand="false" 
label="Html Result" /><br /><br />
<h3>Html Name Type: </h3><cfdump var="#htmlNameType#" expand="false" 
label="Html Name Type" /><br /><br />
<cfdump var="#xmlresult#" expand="false" label="Xml Result" /><br/><br />
<cfdump var="#xmlNameType#" expand="true" label="Xml Name Type" /><br /><br 
/>

</body></html>

//** End Code **//


On Wednesday, March 14, 2012 5:22:12 PM UTC-5, Ben wrote:
>
> I'm trying to do an XMLSearch on an XML object that has a name space. 
>  Here is an example of the data:
>
> <StudentPersonal xmlns="http://www.sifinfo.org/infrastructure/2.x"; 
> RefId="140808190A00040F5007AA16589D65EB">
> <LocalId>20602</LocalId>
> <Name Type="04">
> <LastName>Serrano</LastName>
> <FirstName>Nadine</FirstName>
> <MiddleName>H</MiddleName>
> <FullName>Serrano, Nadine H</FullName>
> </Name>
> </StudentPersonal>
>
>
> If I try to do something as simple as this I get nothing.
> <cfset arrNodes = XmlSearch(temp,"StudentPersonal") />
>
> But, if I remove the namespace piece (xmlns) form the root, then it 
> returns just fine.  Is there something that I am missing with this?  This 
> is OpenBD 2.0.2.
>
> Thanks!
>
> Ben
>
>
>
>
>

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

Reply via email to