Iterating over invalid XML file

Hi,

I have an XML file which contains details as shown below

ASGBGA
3135


aaagdg
3174


oyoyoy
3135

I am iterating over the tag using getXMLNodeIterator. Each document i am writing into separate file.In this case 2nd document is invalid XML so converting xmlNodeToDocument is throwing error Expecting tag and it is coming out of the service without iterating over other tags. Can anybody help me i want to write 2nd to invalid file and should continue iterating over further nodes ??

Name don’t have ending tag in second XML

Ya. I want

aaagdg
3174
This to be written into one file.and continue processing 3rd

Process should not abort if it encounters invalid

Can you pls help this out…

Try to use try/catch mechanisum after initializing iterator. when ever an invalid XML come cursor wil go to catch block and in catch block do noting.

i never tried above senario but remeber someone has posted in forum earlier

Hi Thanks for the suggestion.In Catch block i can write into a file.But after coming out of the Catch block,for next iteration the service getNextXMLNode service is throwing an exception resulting which it is not processing the further nodes.

What is the error you are seeing? node not exist or available for next iteration?

I think, in your case, instead of using xml operations, you should just use String, search for

then,

get the substring of each record, regardless it’s valid xml or no.

If i use node iterator am getting the below error

[ISC.0042.9327]
Expecting got

Can’t i use node iterator to iterate over invalid XML nodes…??

OK it seems to me either your XML has some spl chars or tags are not right in place…can you scan your XML file and check it?

HTH,
RMG

My XML file is not correct because it is missing some tags. How can i iterate over this xml file having missing tags , using xml node iterator…?

I believe it won’t work as expect if the XML is not correct with some tags missing…so please make sure all the XML data is present in the loaded file:

HTH,
RMG