Archived Forum Post

Index of archived forum posts

Question:

vfp, atom nested tag not working .

Mar 28 '13 at 05:50

c_file = "d:/..."
o_atom = CreateObject('Chilkat.atom')
n_success = o_atom.LoadXml(c_file)
IF (n_success <> 1) THEN
=MESSAGEBOX(oatom.LastErrorText)
cancel
ENDIF

*? o_atom.toXmlString()
o_entry = o_atom.getEntry(0)
? "gd:etag=",o_entry.getTopAttr("gd:etag") && ok
? "id1=",o_entry.getElement("id",0) && ok
? "id2=",o_entry.getElement("id",1) && ok, null
? "title1=",o_entry.getElement("title",0) && ok

? "gd:name=",o_entry.getElement("gd:name",0) && error -> null
? "gd:fullname=",o_entry.getElement("gd:fullName",0) && error -> null

? "gd:extendedProperty=",o_entry.getElementAttr("gd:extendedProperty",0,"name") && ok
? "gd:extendedProperty=",o_entry.getElementAttr("gd:extendedProperty",0,"value") && ok

? "getElementCount=",o_entry.getElementCount("link") && ok
? "getLinkHref=",o_entry.getLinkHref("self") && ok
? "getLinkHref=",o_entry.getLinkHref("http://schemas.google.com/contacts/2008/rel#photo") && ok

wait window " ok atom created"
release o_atom


Answer

The problem has to do with the fact that "gd:name" has no actual content as defined by the Chilkat XML API. See http://www.chilkatsoft.com/refdoc/csXmlRef.html

The "gd:name" node has one child node -- namely "gd:fullName", and it in turn has the content "Fitzwilliam Darcy".

    <entry gd:etag="contactEtag">
        &lt;id>http://www.google.com/m8/feeds/contacts/userEmail/base/contactId</id>
        <updated>2008-12-10T04:45:03.331Z</updated>
        <app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-10T04:45:03.331Z</app:edited>
        <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
        <title>Fitzwilliam Darcy</title>
        <gd:name>
            <gd:fullName>Fitzwilliam Darcy</gd:fullName>
        </gd:name>

If the "gd:name" node specified a type of "xml", then the getElement("gd:name") method call would return the full XML contained within it.

For example:

        <gd:name type="xml">
            <gd:fullName>Fitzwilliam Darcy</gd:fullName>
        </gd:name>

If the Chilkat Atom API does not provide a means to directly access the XML content, then you may instead use the Chlikat XML API directly for parsing the XML.


Answer

What do you mean by "not working". We cannot read your mind...


Answer

<gd:name> <gd:fullname> Darcy </gd:fullname> </gd:name>

? o_entry.getElement("gd:Name",0)
i expect " <gd:fullname> Darcy </gd:fullname>"
but the result is empty(not null)
*
? o_entry.getElement("gd:fullName",0)
i expect "Darcy"
but the result is empty(not null)

when i change sample as
<gd:name> Darcy </gd:name>

then it is ok, returns Darcy