Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Feature Request/Issue) Nokogiri does not support css selector for namespaced attributes #593

Closed
kaide opened this issue Jan 7, 2012 · 3 comments

Comments

@kaide
Copy link

kaide commented Jan 7, 2012

Hi i want to manipulate xml files where the attributes have namespace(sql server SSIS package).
I cannot query which elements has attributes' value containing "partial string".
If the attributes does not have any namespace; I can run my query.
too bad my xml contains namespaced attributes.

Just want to inform actual use case of xml document with namespaced attributes. I undestand the dev team is busy.

Thank you

the sample code if needed is at stackOverflow

http://stackoverflow.com/questions/8737622/how-do-i-query-elements-containing-attributenamea-with-namespaceb-with-css

@flavorjones
Copy link
Member

For posterity, the code linked to above looks like:

xmlContent = %Q|
<?xml version="1.0"?>
<ns1:el1 xmlns:ns1="blabla" >
    <ns1:el2 ns1:att="123">with namespace</ns1:el2 >
    <ns1:el2 att="noNameSpace">no namespace</ns1:el2 >
</ns1:el1>|
xml_doc  = Nokogiri::XML(xmlContent)

#no namespace
result = xml_doc.css('ns1|el2[att]')
result.each {|i| puts i}

#with namespace
result = xml_doc.css('ns1|el2[ns1|att]') #error unexpexted '|'
result.each {|i| puts i}

@flavorjones
Copy link
Member

Targetted for release in 1.5.1.

@kaide
Copy link
Author

kaide commented Feb 21, 2012

Thanks; for now I use the xpath syntax for namespaced attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants