Last post Jul 09, 2017 12:49 AM by Lannie
Jul 04, 2017 06:40 PM|KulerMaster|LINK
<?xml version="1.0" encoding="utf-8"?>
<Title>Book No. 1</Title>
<Title>Book No. 2</Title>
How do you parse this XML data? It has a namespace in a string node/element and then there is <pre> tag etc. etc. how do i get rid of those and being able to Parse
only the books using XDocument?
Jul 04, 2017 07:44 PM|Metonymy|LINK
Hello. If you do not want to reinvent the well, best way is to search for an XML Parser.
I'm new to C# and Microsoft so I'm not really sure what to recommend you, but I've found this page:
Check this sample:
XmlDocument xmlDoc= new XmlDocument();
XmlNodeList books = xmlDoc.GetElementsByTagName("books");
Jul 04, 2017 07:54 PM|KulerMaster|LINK
Nah it is just a way to parse well-formed XML. In my case, I need to either get rid of the string and pre tags or to find a way to parse the data as is.
Jul 04, 2017 07:59 PM|Metonymy|LINK
Perhaps construct a new string from the contents of the file skipping the first two new lines?
Jul 05, 2017 04:27 AM|Eric Du|LINK
According to your description, as far as I know, you could operate it with two threads.
1. Remove don't wanted element from the file.
(1) Use SelectSingleNode method to get this element.
(2) Use remove method to remove the child.
(3) Parse the rest element.
2. Parse the specify element, you could use getattribute() method to get the specify element, automatically over that don't wanted elements.
Jul 05, 2017 05:26 AM|KulerMaster|LINK
that thing does not load in XDocument nor XmlDOcument at all. The original string is much worse than the example.
and I am not quite sure how to make it in C#
Jul 09, 2017 12:49 AM|Lannie|LINK
What database are you loading the into?