Re: Need to parse java string with XML data

Posted by Walter Vaughan on
URL: http://ofbiz.116.s1.nabble.com/Need-to-parse-java-string-with-XML-data-tp145266p145272.html

Thanks David & Chris. That's the direction I needed.


David E. Jones wrote:

>
> Here's the method you're looking for:
>
> public static Document readXmlDocument(String content, boolean validate)
>
> Even if you pass false for validate the XML content DOES need to be  at
> least well formed so that the parser can do something with it.
>
> What you passed in isn't actually XML, not just not well formed, but  
> just not XML. It has less than and greater than signs, but that's  about
> where the similarity ends. So, you'd probably have to write a  parser by
> hand and while you could use one of the many good parsing  tool sets out
> there, for something this small a few java.lang.String  operations may
> be sufficient.
>
> -David
>
>
> On Mar 29, 2007, at 12:47 PM, Walter Vaughan wrote:
>
>> Chris Howe wrote:
>>
>>>> <number=3106799433><name=><dnis=2149><state=active>
>>>
>>> I don't believe that to be well-formed XML. I suspect there is a  parent
>>> to those "elements" and if there is, it should look like this...
>>> As child elements:
>>> <parent>
>>>   <number>3106799433</number>
>>>   <name/>
>>>   <dnis>2149</dnis>
>>>   <state>active</state>
>>> </parent>
>>> or..
>>> as attributes:
>>> <parent number="3106799433" name="" dnis="2149" state="active"/>
>>
>>
>> No that's the way it gets kicked to me. I didn't even think to  
>> complain to the server app suppling that data that I'm not getting  
>> valid XML.
>>
>> If I can convince them to supply the data in a well formed XML  
>> layout, do you think I can then convert that to something that can  be
>> used in an ofBiz service?
>>
>> Thanks
>>
>> --
>> Walter
>
>