"Element does not contain a single text node"



  • Ist folgende XML-Code regulär? Mit der Methode GetNodeValue() von _di_IXMLNode kann ich die NodeValue „Barbados“ nicht bekommen, sondern bekomme ich eine Exception „Element does not contain a single text node“. Hat jemand Tipps für mich? Danke!!

    <land id="27">
        Barbados 
        <zielgebiet id="83">
             <![CDATA[ 111]]> 
             <ort id="323">
                Barbados 
                <abpreis>741</abpreis> 
              </ort>
        </zielgebiet>
    </land>
    


  • XMLSpy sagt, dass der Code well-formed ist.
    Was machst Du denn?

    Gruß,

    Alexander



  • Danke, es ist gut zu wissen dass es ein reguläre XML-Code ist.
    Aber mit der Methode GetNodeValue() von _di_IXMLNode kann ich die Node-Werte "Barbados" nicht bekommen.

    Siehe mal Dokumente von BCB-Hilfe.

    Returns the value of this node.

    OleVariant __fastcall GetNodeValue(void);

    Description

    Use the TXMLNode object’s IXMLNode interface to call the protected GetNodeValue method. GetNodeValue returns the value of the node. This value depends on the type of the node, as indicated in the following table:

    NodeType Value
    ----------------------------------------------------
    ntAttribute: The attribute value
    ntElement : If the element contains only text, this is that text value. Otherwise, GetNodeValue raises an exception.
    ntText: The text
    ntCData: The content of the CDATA section.
    ntEntityRef: NULL
    ntProcessingInstr: The content of the processing instruction except for the target.
    ntComment The value (text) of the comment.
    ntDocFragment NULL

    Die Node "land" ist ein "ntElement", wie kann ich ihre Node-Werte bekommen?



  • Sorry, gerade habe ich die Lösung gefunden.

    "Barbados" wird als Node mit Node-Name "#text" von _di_IXMLNode betrachtet. Wenn ich eine Stufe tiefer gehe, dann kann ich schon die Werte bekommen.

    Danke 🙂


Anmelden zum Antworten