Closed bubnenkoff closed 2 years ago
Sorry, I didn't take into account the namespace aspect of XML. But it looks like it ignores namespace by default
I supported namespace selection in version 1.1.0.
In this version, you can use/namespace:local-name
to select nodes with namespaces.
Ignore the namespace with /*[local-name()='name']
Use /*[namespace()='namespace']
to select a namespace.
However, this is not the final plan, please leave me your message, if you have any suggestions and comment.
Sorry, but I can't get it work. I need to extract purchaseNumber
. I tried different approaches like:
final result5 = htmlDom.queryXPath('//*[local-name()="purchaseNumber"]');
Have you upgrade to 1.1.0 or 2.0.0? It works fine for me.
import 'dart:io';
import 'package:xpath_selector/xpath_selector.dart';
Future<void> main() async {
final file = File('test.xml').readAsStringSync();
final selector = XPath.xml(file).query('//*[local-name()="purchaseNumber"]');
print(selector.elements);
}
[<ns9:purchaseNumber>0376200002921000071</ns9:purchaseNumber>, <ns9:purchaseNumber>0159</ns9:purchaseNumber>]
Big thanks! it's work!
Hi! I am trying to parse XML. I need to ignore namespaces. How to do it?