Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Adapter xmlns problem 1

Status
Not open for further replies.

florindaniel

Programmer
Dec 4, 2009
120
RO
Hello,
I'm having this problem when uploading an XML file (a small xml + xsd is attached):
- if I use the xml and xsd files attached, there will be loaded all 87 files but the tables in the XMLAdapter will have 0 records.
- if I delete the xmlns=" from the xml file, the tables can be loaded with no problem.
(in the xml file attached there are only 2 tables, but it is the same behaviour).

here's, in brief, a sample of the code I'm using:

m.oXML = CreateObject("XMLAdapter")
m.oXML.UTF8Encoded = .T.
CREATE DATABASE (Addbs(asDir) + "Nomencla")
m.oXML.XMLSchemaLocation = asXSD
m.oXML.LoadXML(asXML, .T.)
*** m.oXML.Tables.Count = 87 at this point
FOR i = 1 TO m.oXML.Tables.Count
= ParseXMLTable(m.oXML.Tables, asDir)
ENDFOR

FUNCTION ParseXMLTable(m.oXML.Tables, asDir)
LPARAMETERS aoXMLTable, asDir

LOCAL ARRAY laStruDBF[1]
m.oFields = aoXMLTable.Fields

IF m.oFields.Count = 0
RETURN
ENDIF
m.sCursorName = aoXMLTable.Alias
aoXMLTable.ToCursor()
SELECT (m.sCursorName)
COUNT TO m.nCount
*** Here nCount = 0 if xmlns present !!
*** etc...

Thank you,
Daniel
 
Well, from the xsd file, xmlns=" so that is contradicting. I think MSXML (which is used by the XMLADapter) is strict about this, the XML does not meet the schema.

Set m.oXML.XMLNamespace = Strconv(" after having loaded the XML. I get 102 Countries from your XML that way.

Besides: Use Reccount() instead of COUNT TO m.nCount

Bye, Olaf.

sidenote: If you set XMLNamespace to " without Strconv() an error message suggests to set this porperty to a unicode string, which StrConv(string,5) does create, that's the reason for that.
 
That your editing didn't work out may have to do with the way you edit and save the edit. Eg if using notepad, it can save as UTF-8 charset, but it adds unneeded and unwanted bytes to the beginning of the file, which notepad does not dislpay, but XML Parsers see as an infringement.

XML is really a very strict world...

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top