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
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);
You can search for attributes by using @ to add the attrib to the XPATH, e.g. if you would like to query for the attrib title of element book:
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???
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???
you have to either "navigate" in the tree to the appropriate child and then search relativ below this node (this is what you do but without selecting the right parent node before) or can use absolut path or special XPATH notation:
FindNode (XMLNode,'//*/LOGIN',XMLNodeFound)
this indicates that every hierarchy level above LOGIN should be ignored.
Answers
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'.IXMLDOMNamedNodeMap
<book title="Blabla"/>
you would have to search like this
MCP+I, MCSE NT, Navision MCT (2004,2005)
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???
this indicates that every hierarchy level above LOGIN should be ignored.
Or with absolute path:
MCP+I, MCSE NT, Navision MCT (2004,2005)