Which code exactly do you run that gives that error for which statement
Error:{"'', hexadecimal value 0x0B, is an invalid character. Line 1,
position 1."}
Line Code when the error show:
Dim doc As New XPath.XPathDocument(XmlReader.Create(New
StringReader(tempcontent), settings))
How does the input exactly look?
I have a word doc file that I need to read and get the name of address
block.
The paragraph looks like this when I edit the file with notepad.
<br /><br />
SHLOMI HELWA<br />
563 ELTINGVILLE BLVD.<br />
STATEN ISLAND, NY 10312<br />
<br />
<br />
<br />
Does it contain characters that are not allowed in XML, such as control
characters?
So far you have shown only variables with strings of markup.
If you have a file instead then you will need to show how you read the
file contents into a string respectively in terms of XML you would
normally let the XML parser do all that work meaning if you have a file
file1.xml then you would simply change the code I posted to
Please send me an email to jfb00(at)hotmail.com and I can send you the word
file.
I have many word files that I need to collect only the name of an address
block, so I reading and getting the paragraph that contains the address
block.
Here is my code:
Try
'for office xp
wordApp = CreateObject("Word.Application")
wordDoc = CreateObject("Word.document")
Catch
'for office 2000 and 97
wordApp = New Word.Application
wordDoc = New Word.Document
End Try
wordApp.Visible = False
wordDoc = wordApp.Documents.Open(FileName:=docName.ToString)
Dim tempcontent As String = ""
Dim subPara As Word.Paragraph
Dim paraCount As Integer
paraCount = 0
For Each subPara In wordDoc.Paragraphs
tempcontent = subPara.Range.Text
paraCount = paraCount + 1
If paraCount = 5 Then ''Here I get the address block
Exit For
End If
Next
Dim settings As New XmlReaderSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.CheckCharacters = True
Dim doc As New XPath.XPathDocument(XmlReader.Create(New
StringReader(tempcontent), settings))
Dim text As XPath.XPathNavigator =
doc.CreateNavigator().SelectSingleNode("br/following-sibling::text()")
If text IsNot Nothing Then
MsgBox(text.Value)
End If
thanks for your help!