XML import, problem with attribute

juhos1
Member Posts: 5
Problem solved, thank...
0
Answers
-
I don't know how you get the name of the attribute but this is how you can get the value
if you know the name of the attribute (in this case 'NameOfAttributeField')
IF ISCLEAR(lautXMLDoc) THEN
CREATE(lautXMLDoc);
CLEAR(lxmlNode);
lxmlNode := lautXMLDoc.documentElement; //--> Loads first element
CLEAR(lxmlAttribute);
lxmlAttribute := lxmlNode.attributes; //--> Gets attribute(s) in first element
txtAttributeValue := lxmlAttribute.getNamedItem('NameOfAttributeField').text;
--> this is how you get the value of an attribute namend 'NameOfAttributeField
Variables:
Name DataType Subtype Length
lautXMLDoc Automation 'Microsoft XML, v6.0'.DOMDocument
lxmlNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
lxmlAttribute Automation 'Microsoft XML, v6.0'.IXMLDOMNamedNodeMap0 -
juhos1 wrote:Help me,
I use xml to import standard procedure: FindNode, whitch parse elements, but I dont read attribute element.
Can anybody suggest some solutions???
I use Navision 4.00 SP1.
Thank.
Procedure FindNode
Var Name DataType Subtype Length
Nie XMLRootNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
Nie NodePath Text 250
Áno FoundXMLNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
IF ISCLEAR(XMLRootNode) THEN
EXIT(FALSE);
IF NOT NormalCaseMode THEN
NodePath := UPPERCASE(NodePath);
FoundXMLNode := XMLRootNode.selectSingleNode(NodePath);
IF ISCLEAR(FoundXMLNode) THEN
EXIT(FALSE)
ELSE
EXIT(TRUE);
<book title="Blabla"/>
you would have to search like thisXMLRootNode.selectSingleNode('/book/@title');
Torsten
MCP+I, MCSE NT, Navision MCT (2004,2005)0 -
Thank all for help. But I have another problem.
I Can load element what is first, but I dont load elements what are other positions.
Example:
<?xml version="1.0" encoding="utf-8" ?>
- <REQUEST TERMID="102">
-- <GETUSERINFO>
--- <LOGIN>RAVEN</LOGIN>
--- <LOGIN2>RAVEN2</LOGIN2>
-- </GETUSERINFO>
- </REQUEST>
Procedure FindNode (XMLNode,'LOGIN',XMLNodeFound) not found RAVEN. Why?
Only if I use procedure FindNode (XMLNode,'GETUSERINFO',XMLNodeFound), so procedure give back RAVENRAVEN2.
Procedure FINDNODE is describe thereinbefore.
Can anybody suggest some solutions, how to search element 'LOGIN' in xml file???0 -
juhos1 wrote:Thank all for help. But I have another problem.
I Can load element what is first, but I dont load elements what are other positions.
Example:
<?xml version="1.0" encoding="utf-8" ?>
- <REQUEST TERMID="102">
-- <GETUSERINFO>
--- <LOGIN>RAVEN</LOGIN>
--- <LOGIN2>RAVEN2</LOGIN2>
-- </GETUSERINFO>
- </REQUEST>
Procedure FindNode (XMLNode,'LOGIN',XMLNodeFound) not found RAVEN. Why?
Only if I use procedure FindNode (XMLNode,'GETUSERINFO',XMLNodeFound), so procedure give back RAVENRAVEN2.
Procedure FINDNODE is describe thereinbefore.
Can anybody suggest some solutions, how to search element 'LOGIN' in xml file???FindNode (XMLNode,'//*/LOGIN',XMLNodeFound)
this indicates that every hierarchy level above LOGIN should be ignored.
Or with absolute path:FindNode (XMLNode,'//REQUEST/GETUSERINFO/LOGIN',XMLNodeFound)
Torsten
MCP+I, MCSE NT, Navision MCT (2004,2005)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions