|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
Hi everyone,
I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working fine with other applications. Can someone help? Here is my code: *----------------------------------------------------------------------------------- STATIC FUNCTION XMLDecode( o, XMLData ) LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) LOCAL oXmlNode, oBrw IF oXmlDoc:nError != 0 MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) RETURN NIL ENDIF *--------------------------- Thank you, Reinaldo. |
|
|
||||
|
||||
|
|
|
|||
|
Hello,
Please show us the exact string you have passed into the NEW(...) method, and has raised error. Ella On Monday, June 25, 2012 12:50:28 AM UTC+3, Reinaldo wrote: > Hi everyone, > > I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. > > oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working fine with other applications. > > Can someone help? > > Here is my code: > > *----------------------------------------------------------------------------------- > STATIC FUNCTION XMLDecode( o, XMLData ) > LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) > LOCAL oXmlNode, oBrw > > > IF oXmlDoc:nError != 0 > MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) > RETURN NIL > ENDIF > > > *--------------------------- > > Thank you, > > > Reinaldo. |
|
|||
|
Ella;
Hi. Thank you for asking. This is one such string being feed: <?xml version="1.0" encoding="utf-8"?> <Facilities> <1>LAS AMERICAS AMB. SURG. CENTER</1> </Facilities> <Referrings> <1>002</1> <2>003</2> <3>004</3> <4>005</4> <5>006</5> <6>007</6> <7>008</7> </Referrings> <Classifications> <1>CANCER BUREAU</1> </Classifications> <Pathology Types/> <Medical Specialties/> <Pathologists/> <Routes/> <CopyTos/> <OtherVars> <Version></Version> </OtherVars> Reinaldo. On Sunday, June 24, 2012 6:24:19 PM UTC-4, Ella Stern wrote: > Hello, > > Please show us the exact string you have passed into the NEW(...) method, and has raised error. > > Ella > > > > On Monday, June 25, 2012 12:50:28 AM UTC+3, Reinaldo wrote: > > Hi everyone, > > > > I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. > > > > oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working fine with other applications. > > > > Can someone help? > > > > Here is my code: > > > > *----------------------------------------------------------------------------------- > > STATIC FUNCTION XMLDecode( o, XMLData ) > > LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) > > LOCAL oXmlNode, oBrw > > > > > > IF oXmlDoc:nError != 0 > > MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) > > RETURN NIL > > ENDIF > > > > > > *--------------------------- > > > > Thank you, > > > > > > Reinaldo. |
|
|||
|
On Monday, June 25, 2012 10:14:53 AM UTC-4, Reinaldo wrote:
> Ella; > > Hi. Thank you for asking. > > This is one such string being feed: > > <?xml version="1.0" encoding="utf-8"?> > <Facilities> > <1>LAS AMERICAS AMB. SURG. CENTER</1> > </Facilities> > <Referrings> > <1>002</1> > <2>003</2> > <3>004</3> > <4>005</4> > <5>006</5> > <6>007</6> > <7>008</7> > </Referrings> > <Classifications> > <1>CANCER BUREAU</1> > </Classifications> > <Pathology Types/> > <Medical Specialties/> > <Pathologists/> > <Routes/> > <CopyTos/> > <OtherVars> > <Version></Version> > </OtherVars> > > Reinaldo. > > > On Sunday, June 24, 2012 6:24:19 PM UTC-4, Ella Stern wrote: > > Hello, > > > > Please show us the exact string you have passed into the NEW(...) method, and has raised error. > > > > Ella > > > > > > > > On Monday, June 25, 2012 12:50:28 AM UTC+3, Reinaldo wrote: > > > Hi everyone, > > > > > > I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. > > > > > > oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working fine with other applications. > > > > > > Can someone help? > > > > > > Here is my code: > > > > > > *----------------------------------------------------------------------------------- > > > STATIC FUNCTION XMLDecode( o, XMLData ) > > > LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) > > > LOCAL oXmlNode, oBrw > > > > > > > > > IF oXmlDoc:nError != 0 > > > MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) > > > RETURN NIL > > > ENDIF > > > > > > > > > *--------------------------- > > > > > > Thank you, > > > > > > > > > Reinaldo. Problem solved. Thank you. Reinaldo. |
|
|||
|
Hello,
The answer is a bit lenghty. In xHarbour an XML tagname is checked to assure, that it's starting with a letter. See /trl/hbxml.c function mxml_node_read_name(...) In XML a tagname should always start with a LETTER, or certain other symbols, which are not recommended to be used (by different articles). This recommendation is present since 1998 in W3.org documentation here: http://www.w3.org/TR/1998/REC-xml-19...sec-common-syn Chapter 2.3 "A Name is a token beginning with a letter or one of a few punctuation characters..." The posted XML structure is or older then 15 years, or its authors are working with a database, which permits field names to start with a number - not the case in xHarbour. Ella On Monday, June 25, 2012 5:14:53 PM UTC+3, Reinaldo wrote: > Ella; > > Hi. Thank you for asking. > > This is one such string being feed: > > <?xml version="1.0" encoding="utf-8"?> > <Facilities> > <1>LAS AMERICAS AMB. SURG. CENTER</1> > </Facilities> > <Referrings> > <1>002</1> > <2>003</2> > <3>004</3> > <4>005</4> > <5>006</5> > <6>007</6> > <7>008</7> > </Referrings> > <Classifications> > <1>CANCER BUREAU</1> > </Classifications> > <Pathology Types/> > <Medical Specialties/> > <Pathologists/> > <Routes/> > <CopyTos/> > <OtherVars> > <Version></Version> > </OtherVars> > > Reinaldo. > > > On Sunday, June 24, 2012 6:24:19 PM UTC-4, Ella Stern wrote: > > Hello, > > > > Please show us the exact string you have passed into the NEW(...) method, and has raised error. > > > > Ella > > > > > > > > On Monday, June 25, 2012 12:50:28 AM UTC+3, Reinaldo wrote: > > > Hi everyone, > > > > > > I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. > > > > > > oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working fine with other applications. > > > > > > Can someone help? > > > > > > Here is my code: > > > > > > *----------------------------------------------------------------------------------- > > > STATIC FUNCTION XMLDecode( o, XMLData ) > > > LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) > > > LOCAL oXmlNode, oBrw > > > > > > > > > IF oXmlDoc:nError != 0 > > > MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) > > > RETURN NIL > > > ENDIF > > > > > > > > > *--------------------------- > > > > > > Thank you, > > > > > > > > > Reinaldo. |
|
|||
|
On Monday, June 25, 2012 1:47:32 PM UTC-4, Ella Stern wrote:
> Hello, > > The answer is a bit lenghty. > In xHarbour an XML tagname is checked to assure, that it's starting with a letter. See /trl/hbxml.c function mxml_node_read_name(...) > > In XML a tagname should always start with a LETTER, or certain other symbols, which are not recommended to be used (by different articles). > > This recommendation is present since 1998 in W3.org documentation here: > > http://www.w3.org/TR/1998/REC-xml-19...sec-common-syn > Chapter 2.3 > > "A Name is a token beginning with a letter or one of a few punctuation characters..." > > The posted XML structure is or older then 15 years, or its authors are working with a database, which permits field names to start with a number - not the case in xHarbour. > > Ella > > > > On Monday, June 25, 2012 5:14:53 PM UTC+3, Reinaldo wrote: > > Ella; > > > > Hi. Thank you for asking. > > > > This is one such string being feed: > > > > <?xml version="1.0" encoding="utf-8"?> > > <Facilities> > > <1>LAS AMERICAS AMB. SURG. CENTER</1> > > </Facilities> > > <Referrings> > > <1>002</1> > > <2>003</2> > > <3>004</3> > > <4>005</4> > > <5>006</5> > > <6>007</6> > > <7>008</7> > > </Referrings> > > <Classifications> > > <1>CANCER BUREAU</1> > > </Classifications> > > <Pathology Types/> > > <Medical Specialties/> > > <Pathologists/> > > <Routes/> > > <CopyTos/> > > <OtherVars> > > <Version></Version> > > </OtherVars> > > > > Reinaldo. > > > > > > On Sunday, June 24, 2012 6:24:19 PM UTC-4, Ella Stern wrote: > > > Hello, > > > > > > Please show us the exact string you have passed into the NEW(...) method, and has raised error. > > > > > > Ella > > > > > > > > > > > > On Monday, June 25, 2012 12:50:28 AM UTC+3, Reinaldo wrote: > > > > Hi everyone, > > > > > > > > I wonder if anyone has had any success using xharbour TxmlDocument class. So far I'm able to create an xml document alright but cant open and parse ANY xml document. > > > > > > > > oXmlDoc := TXmlDocument():New( cXmlString ) always returns 4 on oXmlDoc:nError. I've tried using xml documents that I know are working finewith other applications. > > > > > > > > Can someone help? > > > > > > > > Here is my code: > > > > > > > > *----------------------------------------------------------------------------------- > > > > STATIC FUNCTION XMLDecode( o, XMLData ) > > > > LOCAL oXmlDoc := TXmlDocument():New( XMLData, HBXML_STYLE_NOESCAPE ) > > > > LOCAL oXmlNode, oBrw > > > > > > > > > > > > IF oXmlDoc:nError != 0 > > > > MsgStop( "Error Parsing XML: " + hb_XmlErrorDesc( oXmlDoc:nError ) ) > > > > RETURN NIL > > > > ENDIF > > > > > > > > > > > > *--------------------------- > > > > > > > > Thank you, > > > > > > > > > > > > Reinaldo. Ella; That's actually a very good explanation. I was able to figure out a workaround by parsing the string myself but it surely feels good to understand that the source of the problem has nothing to do with the xharbour implementation of xml. Thank you very much. Reinaldo. Reinaldo. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|