Progress Sax-reader获取XML节点place-id属性值问题求助
place-id Hey there! Let's get your SAX reader code working to pull that place-id attribute value.
First, let's break down why your current code isn't working: the GET-VALUE-BY-NAMESPACE-NAME() method is designed specifically for attributes that belong to an XML namespace. Looking at your target node:
<address ssid="32975" place-id="11537" quality="good">
None of these attributes are tied to a namespace (there's no xmlns: prefix or namespace declaration associated with them), so this method isn't the right tool for the job.
Correct Code Approach
Instead, use the GET-VALUE() method, which is built to retrieve attribute values that don't use namespaces. Here's how to adjust your CASE statement:
WHEN "address" THEN ASSIGN lv-place-id = charData.GET-VALUE('place-id').
A Quick Note on Namespaces (For Future Reference)
If you ever encounter attributes with a namespace (e.g., <address xmlns:loc="http://example.com/locations" loc:place-id="11537">), that's when you'd reach for GET-VALUE-BY-NAMESPACE-NAME(). In that scenario, you'd pass the namespace URI first, then the attribute's local name:
ASSIGN lv-place-id = charData.GET-VALUE-BY-NAMESPACE-NAME('http://example.com/locations', 'place-id').
This should resolve your current issue and get you pulling that place-id value successfully!
内容的提问来源于stack exchange,提问作者Stephen Kennedy

