AGB  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

XPathException

Ein Thema von Cogito · begonnen am 4. Jan 2012 · letzter Beitrag vom 9. Jan 2012
Antwort Antwort
Cogito

Registriert seit: 12. Jun 2008
273 Beiträge
 
#1

XPathException

  Alt 4. Jan 2012, 09:11
Hallo zusammen,

ich bekomme an einer Stelle meines Programms eine XPathException mit folgendem Text:

Code:
************** Exception Text **************
System.Xml.XPath.XPathException: 'companies/company[displayName=Monterey Holdings I Sàrl]' has an invalid token.
   at MS.Internal.Xml.XPath.XPathParser.CheckToken(LexKind t)
   at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput)
   at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion)
   at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar, Boolean allowKey)
   at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean& needContext)
   at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
   at System.Xml.XPath.XPathNavigator.Compile(String xpath)
   at PDFViewer.FormSaveAs.cb_action_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Kann einer von euch mir sagen welches Token hier ungültig ist (ich vermute mal das es das Zeichen à ist) ?
  Mit Zitat antworten Zitat
Benutzerbild von Phoenix
Phoenix
(Moderator)
Online

Registriert seit: 25. Jun 2002
Ort: Hausach
6.962 Beiträge
 
Delphi 2010 Professional
 
#2

AW: XPathException

  Alt 4. Jan 2012, 10:19
Versuch mal:
Code:
companies/company[displayName=Monterey Holdings I Sàrl]
Sebastian P.R. Gingter
不死鳥 Visit my Blog.
Do not argue with an idiot. They lower you to their level and then try to beat you with experience.
  Mit Zitat antworten Zitat
Cogito

Registriert seit: 12. Jun 2008
273 Beiträge
 
#3

AW: XPathException

  Alt 5. Jan 2012, 13:27
Der Kunde sagte mir gerade, dass sie in den XML Dateien nichts ändern können. Ausserdem wird diese XML Datei automatisiert erzeugt und auch noch in anderen Programmen weiterverwendet. Und nu?
  Mit Zitat antworten Zitat
Cogito

Registriert seit: 12. Jun 2008
273 Beiträge
 
#4

AW: XPathException

  Alt 9. Jan 2012, 08:57
Sagt mal, es müsste doch meines Erachtens eine Funktion oder API oder sonstwas geben, die einen String in einen gültigen XPath Ausdruck umwandelt. Ansonsten hätten doch alle Franzosen oder Chinesen Probleme. Kennt einer von euch so eine Funktion?
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
22.951 Beiträge
 
Delphi XE2 Professional
 
#5

AW: XPathException

  Alt 9. Jan 2012, 09:10
Ich vergeß immer wie die heißt, aber ja, gibt es.

Scheu mal beim HTML, wie dort diese Sonderzeichen kodiert werden.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
Delphi-Tage 2012
  Mit Zitat antworten Zitat
Cogito

Registriert seit: 12. Jun 2008
273 Beiträge
 
#6

AW: XPathException

  Alt 9. Jan 2012, 09:45
Ich vergeß immer wie die heißt, aber ja, gibt es.

Scheu mal beim HTML, wie dort diese Sonderzeichen kodiert werden.
Das Kodieren einzelner Zeichen nützt mir aber nicht viel, da ich unmöglich alle möglichen Zeichen umwandeln kann. Ich bräuchte also eine Funktion die einen string auf diese Zeichen abklopft und mir dann einen xpath gültigen String zurückliefert. Kannst du versuchen dich an den Namen der Funktion zu erinnern?
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
21.058 Beiträge
 
Delphi XE Professional
 
#7

AW: XPathException

  Alt 9. Jan 2012, 09:51
In PHP gibt es htmlentities, vielleicht existiert eine Funktion mit ähnlichem Namen?

[edit] Oder hilft Dir vielleicht HTTPUtil.HTMLEscape weiter? [/edit]

[edit2] *Oops*, es geht ja gar nicht um Delphi [/edit2]
Detlef
Wenn Dein Programm nicht macht, was es soll, nenn es einfach "Version 1.0"

Delphi programming is cool

Geändert von DeddyH ( 9. Jan 2012 um 10:03 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Phoenix
Phoenix
(Moderator)
Online

Registriert seit: 25. Jun 2002
Ort: Hausach
6.962 Beiträge
 
Delphi 2010 Professional
 
#8

AW: XPathException

  Alt 9. Jan 2012, 10:01
HttpUtility.EncodeHtml() im System.Web assembly dürfte da helfen.
Du darfst das aber nicht über das komplette XML laufen lassen sondern nur über die XPath-Ausdrücke.
Sebastian P.R. Gingter
不死鳥 Visit my Blog.
Do not argue with an idiot. They lower you to their level and then try to beat you with experience.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2012 by Daniel R. Wolf